#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#include "debug.cpp"
#else
#define debug(...)
#endif
signed main() {
ios_base::sync_with_stdio(false);cin.tie(0);
int n,q;
cin>>n>>q;
deque<int> v;
vector<int> ver;
ver.push_back({});
for(int i = 0;i<n;i++){
int x;cin>>x;
ver.push_back(x);
v.push_back(x);
}
int a,b;cin>>a>>b;
while(a--){
deque<int> p1,p2,all;
int x = n/2;
while(x--){
p1.push_back(v[0]);v.pop_front();
}
x = n/2;
while(x--){
p2.push_back(v[0]);v.pop_front();
}
while(p1.size()&&p2.size()){
if(p1[0]<p2[0]){
all.push_back(p1[0]);p1.pop_front();
}else{
all.push_back(p2[0]);p2.pop_front();
}
}
while(p1.size()){
all.push_back(p1[0]);p1.pop_front();
}while(p2.size()){
all.push_back(p2[0]);p2.pop_front();
}
swap(v,all);bool ss = 0;
for(int i = 0;i<n;i++){
if(ver[i]!=v[i]){
ss = 1;
}
}
if(!ss)break;
ver.clear();
for(int i = 0;i<n;i++){
ver.push_back(v[i]);
}
}
q--;
cout<<ver[b-1]<<endl;
while(q--){
int a,b;cin>>a>>b;
cout<<ver[b-1]<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1248 ms |
4120 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3030 ms |
2132 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3031 ms |
1116 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1248 ms |
4120 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |