Submission #896044

#TimeUsernameProblemLanguageResultExecution timeMemory
896044n3rm1nUntitled (POI11_tem)C++17
24 / 100
1060 ms17092 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; const int MAXN = 1e6 + 10; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n; int ad[MAXN], au[MAXN]; int inf = -1e9-10; void read() { cin >> n; int xx, yy; for (int i = 1; i <= n; ++ i) { cin >> ad[i] >> au[i]; } } int t[MAXN * 4]; void make_tree(int i, int l, int r) { if(l == r) { t[i] = ad[l]; return; } int mid = (l + r)/2; make_tree(2*i, l, mid); make_tree(2*i+1, mid+1, r); t[i] = max(t[2*i], t[2*i+1]); } int ql, qr; int query(int i, int l, int r) { if(qr < l || ql > r)return inf; if(ql <= l && r <= qr)return t[i]; int mid = (l + r)/2; return max(query(2*i, l, mid), query(2*i+1, mid+1, r)); } int main() { speed(); read(); make_tree(1, 1, n); int ans = 0; int last = 1; int left, right, mid, border, maxx; for (int i = 1; i <= n; ++ i) { left = last; right = i; border = i; while(left <= right) { mid = (left + right)/2; ql = mid; qr = i; maxx = query(1, 1, n); if(maxx > au[i]) { left = mid + 1; } else { border = mid; right = mid - 1; } } last = border; //cout << i << " " << border << endl; ans = max(ans, i - border + 1); } cout << ans << endl; return 0; }

Compilation message (stderr)

tem.cpp: In function 'void read()':
tem.cpp:17:9: warning: unused variable 'xx' [-Wunused-variable]
   17 |     int xx, yy;
      |         ^~
tem.cpp:17:13: warning: unused variable 'yy' [-Wunused-variable]
   17 |     int xx, yy;
      |             ^~
#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...