제출 #1118886

#제출 시각아이디문제언어결과실행 시간메모리
1118886ZflopHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
0 / 100
1717 ms124048 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int NMAX = (int)1e6 + 50; vector<vector<int>>R[NMAX]; int N,M,A[NMAX],ans[NMAX],mx[NMAX * 4]; void make(int i,int v,int l,int r,int x) { if (l == r) { mx[x] = max(mx[x],v); return; } int mid = (l + r) / 2; if (i <= mid) make(i,v,l,mid,2 * x); else make(i,v,mid + 1,r,2 * x + 1); mx[x] = max(mx[2 * x],mx[2 * x + 1]); } int get_maxim(int a,int b,int l,int r,int x) { if (a <= l && r <= b) return mx[x]; if (r < a || b < l) return 0; int mid = (l + r) / 2; return max(get_maxim(a,b,l,mid,2 * x),get_maxim(a,b,mid + 1,r,2 * x + 1)); } void solve() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> M; for (int i = 1; i <= N;++i) cin >> A[i]; for (int i = 1; i <= M;++i) { int l,r,k; cin >> l >> r >> k; make(i,A[i],1,N,1); R[r].push_back({l,k,i}); } A[N + 1] = (int)1e9 * 2; stack<int>q; q.push(N + 1); for (int i = 1; i <= N;++i) { while (A[i] >= A[q.top()]) q.pop(); make(q.top(),A[i] + A[q.top()],1,N,1); q.push(i); for (auto q : R[i]) { ans[q[2]] = get_maxim(q[0],i,1,N,1) <= q[1]; } } for (int i = 1; i <= M;++i) { cout << ans[i] << '\n'; //cout << i << ' '; } } main() { solve(); }

컴파일 시 표준 에러 (stderr) 메시지

sortbooks.cpp:62:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   62 | main() {
      | ^~~~
#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...