Submission #30072

#TimeUsernameProblemLanguageResultExecution timeMemory
30072tlwpdusUntitled (POI11_tem)C++11
100 / 100
439 ms12604 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; int n; int S[1000100], E[1000100]; deque<pii> dq; void push(pii a) { while(!dq.empty()&&dq.back().second<=a.second) dq.pop_back(); dq.push_back(a); } int main() { int i, j, res = 1; scanf("%d",&n); for (i=0;i<n;i++) scanf("%d%d",&S[i],&E[i]); i = 0; j = -1; for (;i<n;i++) { if (!dq.empty()&&dq.front().first<i) dq.pop_front(); if (j<i) {j=i;push(pii(j,S[j]));} for (;j+1<n;) { if (dq.front().second<=E[j+1]) {j++;push(pii(j,S[j]));} else break; } res = max(res,j-i+1); } printf("%d\n",res); return 0; }

Compilation message (stderr)

tem.cpp: In function 'int main()':
tem.cpp:18:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
tem.cpp:19:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i=0;i<n;i++) scanf("%d%d",&S[i],&E[i]);
                                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...