This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N, L[1000005], R[1000005];
int main(){
cin.tie(0) -> sync_with_stdio(0);
cin >> N;
for(ll i = 1; i <= N; i++){
cin >> L[i] >> R[i];
}
ll Ans = 0;
deque<int> dq;
for(ll i = 1, j = 0; i <= N; i++){
while(j < N && (dq.empty() || R[j + 1] >= L[dq.front()])){
j++;
while(!dq.empty() && L[dq.back()] <= L[j]) dq.pop_back();
dq.push_back(j);
}
while(!dq.empty() && dq.front() <= i) dq.pop_front();
Ans = max(Ans, j - i + 1);
}
cout << Ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |