제출 #1010733

#제출 시각아이디문제언어결과실행 시간메모리
1010733pccSushi (JOI16_sushi)C++17
5 / 100
12034 ms2284 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,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++){ (arr[i]>a?swap(a,arr[i]):void()); } for(int i = 1;i<=r;i++)(arr[i]>a?swap(a,arr[i]):void()); } else{ for(int i = l;i<=r;i++)(arr[i]>a?swap(a,arr[i]):void()); } 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...