Submission #1115056

#TimeUsernameProblemLanguageResultExecution timeMemory
1115056staszic_ojuzFire (JOI20_ho_t5)C++17
7 / 100
105 ms7112 KiB
#include <bits/stdc++.h> using namespace std; int tr[400000]; int n,q; void add(int p,int w) { p+=n; tr[p] = w; p/=2; while(p > 0) { tr[p] = max(tr[p*2],tr[p*2+1]); p/=2; } } int spr(int l,int r) { l+=n;r+=n; int ans = 0; ans = max(ans, tr[l]); ans = max(ans, tr[r]); while(l/2 != r/2) { if(l%2 == 0) ans = max(ans,tr[l+1]); if(r%2 == 1) ans = max(ans,tr[r-1]); l/=2;r/=2; } return ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>q; for(int i = 0;i<n;i++) { int x; cin>>x; add(i,x); } for(int i = 0;i<q;i++) { int t,l,r; cin>>t>>l>>r; l--;r--; cout<<spr(max(0,l-t),r)<<"\n"; } }
#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...