This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |