Submission #1010725

#TimeUsernameProblemLanguageResultExecution timeMemory
1010725pccSushi (JOI16_sushi)C++17
5 / 100
12084 ms6688 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx2,popcnt,sse4") const int mxn = 4e5+10; int arr[mxn]; int N,Q; int ans[mxn]; int ptr = 0; int main(){ cin>>N>>Q; for(int i = 1;i<=N;i++)cin>>arr[i]; for(int j = 0;j<Q;j++){ int l,r,a; cin>>l>>r>>a; if(l>r){ for(int i = l;i<=N;i++)if(arr[i]>a)swap(a,arr[i]); for(int i = 1;i<=r;i++)if(arr[i]>a)swap(a,arr[i]); } else{ for(int i = l;i<=r;i++)if(arr[i]>a)swap(arr[i],a); } ans[ptr++] = a; } for(int i = 0;i<Q;i++)cout<<ans[i]<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...