이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll 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<ll> dq;
for(ll i = 1, j = 1; i <= N; i++){
while(!dq.empty() && L[dq.back()] <= L[i]) dq.pop_back();
dq.push_back(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... |