#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> 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];
}
int ind1 = 0;
int ind2 = 0;
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(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++;
}
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 |
175 ms |
5456 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3048 ms |
4832 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3044 ms |
2828 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
175 ms |
5456 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |