#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<pair<int,int>> v(n);
for(int i = 0; i < n; i++) {
cin >> v[i].first >> v[i].second;
}
int j = 0;
queue<int> s;
int ans = 0;
for(int i = 0; i < n; i++) {
j = max(j, i);
while(j < n && (s.empty() || v[j].second >= v[s.front()].first)) {
while(!s.empty() && v[s.front()].first <= v[j].first) s.pop();
s.push(j);
j++;
}
ans = max(ans, j - i);
if(!s.empty() && s.front() == i) s.pop();
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
2 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
492 KB |
Output is correct |
2 |
Correct |
3 ms |
492 KB |
Output is correct |
3 |
Correct |
3 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
4844 KB |
Output is correct |
2 |
Correct |
86 ms |
5356 KB |
Output is correct |
3 |
Correct |
94 ms |
7584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
154 ms |
6508 KB |
Output is correct |
2 |
Correct |
164 ms |
7740 KB |
Output is correct |
3 |
Correct |
167 ms |
9324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
194 ms |
6892 KB |
Output is correct |
2 |
Correct |
175 ms |
7404 KB |
Output is correct |
3 |
Correct |
200 ms |
9068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
221 ms |
7436 KB |
Output is correct |
2 |
Correct |
189 ms |
19308 KB |
Output is correct |
3 |
Correct |
256 ms |
31392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
197 ms |
7404 KB |
Output is correct |
2 |
Correct |
180 ms |
9580 KB |
Output is correct |
3 |
Correct |
177 ms |
18924 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
122 ms |
7788 KB |
Output is correct |
2 |
Correct |
127 ms |
9708 KB |
Output is correct |
3 |
Correct |
127 ms |
12268 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
126 ms |
6892 KB |
Output is correct |
2 |
Correct |
128 ms |
10092 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
188 ms |
6508 KB |
Output is correct |
2 |
Correct |
252 ms |
10604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
174 ms |
6124 KB |
Output is correct |
2 |
Correct |
227 ms |
9460 KB |
Output is correct |