#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(0);
int n,q;
cin >> n >> q;
vector <int> v(n);
vector <int> vlast(n);
vector <int> res(n);
for(int i = 0;i < n;i++){
cin >> v[i];
}
for(int k = 0;k < q;k++){
int a,b;
cin >> a >> b;
if(k == 0){
int num = 0;
while(num < a){
vector<int> v1(n/2);
vector<int> v2(n/2);
for(int i = 0;i < n/2;i++){
v1[i] = v[i];
v2[i] = v[i+n/2];
vlast[i] = v[i];
vlast[i+n/2] = v[i+n/2];
}
int ind1 = 0;
int ind2 = 0;
bool same = true;
while(ind1 < n/2 && ind2 < n/2){
if(v1[ind1] < v2[ind2]){
v[ind1+ind2] = v1[ind1];
ind1++;
}else{
v[ind1+ind2] = v2[ind2];
ind2++;
}
if(v[ind1+ind2-1] != vlast[ind1+ind2-1]){
same = false;
}
}
if(ind1 < n/2){
for(int j = ind1;j < n/2;j++){
v[j+ind2] = v1[j];
}
}else{
for(int j = ind2;j < n/2;j++){
v[j+ind1] = v2[j];
}
}
num++;
if(same){
break;
}
}
for(int j = 0;j < n;j++){
res[j] = v[j];
}
}
cout << res[b-1] << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
146 ms |
4176 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3043 ms |
4252 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3033 ms |
2520 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
146 ms |
4176 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |