#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++)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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
452 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
344 KB |
Output is correct |
9 |
Correct |
3 ms |
460 KB |
Output is correct |
10 |
Correct |
3 ms |
444 KB |
Output is correct |
11 |
Correct |
4 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
348 KB |
Output is correct |
13 |
Correct |
5 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
348 KB |
Output is correct |
15 |
Correct |
4 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8112 ms |
2328 KB |
Output is correct |
2 |
Correct |
7435 ms |
2084 KB |
Output is correct |
3 |
Correct |
3775 ms |
1932 KB |
Output is correct |
4 |
Correct |
7992 ms |
2272 KB |
Output is correct |
5 |
Correct |
2686 ms |
2244 KB |
Output is correct |
6 |
Execution timed out |
12029 ms |
6224 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
452 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
344 KB |
Output is correct |
9 |
Correct |
3 ms |
460 KB |
Output is correct |
10 |
Correct |
3 ms |
444 KB |
Output is correct |
11 |
Correct |
4 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
348 KB |
Output is correct |
13 |
Correct |
5 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
348 KB |
Output is correct |
15 |
Correct |
4 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
8112 ms |
2328 KB |
Output is correct |
24 |
Correct |
7435 ms |
2084 KB |
Output is correct |
25 |
Correct |
3775 ms |
1932 KB |
Output is correct |
26 |
Correct |
7992 ms |
2272 KB |
Output is correct |
27 |
Correct |
2686 ms |
2244 KB |
Output is correct |
28 |
Execution timed out |
12029 ms |
6224 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |