#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 1e6 + 5;
int n, mn, mx, ans, x;
deque<pair<int, int>> dq;
int main(void){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 0; i < n; i++){
cin >> mn >> mx; x = i;
while(dq.size() && dq.front().fi > mx) dq.pop_front();
while(dq.size() && dq.back().fi <= mn) {
x = dq.back().se; dq.pop_back();
}
dq.emplace_back(mn, x);
ans = max(ans, i - dq.front().se + 1);
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
72 ms |
312 KB |
Output is correct |
2 |
Correct |
75 ms |
3876 KB |
Output is correct |
3 |
Correct |
81 ms |
4128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
123 ms |
428 KB |
Output is correct |
2 |
Correct |
146 ms |
11572 KB |
Output is correct |
3 |
Correct |
177 ms |
13500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
162 ms |
428 KB |
Output is correct |
2 |
Correct |
172 ms |
11952 KB |
Output is correct |
3 |
Correct |
228 ms |
19024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
227 ms |
340 KB |
Output is correct |
2 |
Correct |
213 ms |
12336 KB |
Output is correct |
3 |
Correct |
242 ms |
23296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
186 ms |
876 KB |
Output is correct |
2 |
Correct |
164 ms |
11084 KB |
Output is correct |
3 |
Correct |
183 ms |
12060 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
156 ms |
424 KB |
Output is correct |
2 |
Correct |
132 ms |
5664 KB |
Output is correct |
3 |
Correct |
118 ms |
5844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
113 ms |
424 KB |
Output is correct |
2 |
Correct |
153 ms |
5796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
144 ms |
428 KB |
Output is correct |
2 |
Correct |
278 ms |
23284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
191 ms |
432 KB |
Output is correct |
2 |
Correct |
239 ms |
20848 KB |
Output is correct |