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;
const int maxN = 1e6 + 10;
const int inf = 0x3f3f3f3f;
int a[maxN], b[maxN];
signed main(){
int n;
cin >> n;
for (int i = 1; i <= n; ++i){
cin >> a[i] >> b[i];
}
deque <int> Q;
int i = 1, j = 0;
b[n + 1] = -inf;
int ans = 1;
while (i <= n){
while (!Q.empty() && Q.front() < i) Q.pop_front();
if (j < i){
j = i;
Q.push_back(i);
}
while (j <= n && a[Q.front()] <= b[j + 1]){
++j;
while (!Q.empty() && a[Q.back()] <= a[j]) Q.pop_back();
Q.push_back(j);
}
ans = max(ans, j - i + 1);
++i;
}
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... |