提交时间:2022-07-19 11:51:17
运行 ID: 52259
#include <bits/stdc++.h> using namespace std; int l[500100],r[500100]; int main(){ int n,a,b,maxn = -100,k; cin>>n; for (int i=1;i<=n;i++){ cin>>l[i]>>r[i]; if (r[i]-l[i]>=maxn) { maxn = r[i] - l[i]; a = l[i];b = r[i]; k = i; } } int ans = 1; for (int i=1;i<=n;i++){ if (i == k) continue; else if (r[i]-l[i]<=maxn&&r[i]<=b&&l[i]>=a){ maxn = r[i]-l[i]; a = l[i]; b = r[i]; ans++; } } cout<<ans<<endl; return 0; }