#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, q; cin >> n >> q;
vector<int> v(n);
for(int &x: v) cin >> x, x--;
vector<tuple<int, int, int>> queries;
for(int i = 0; i < q; i++){
int t, I; cin >> t >> I; I--;
queries.pb({t, I, i});
}
sort(queries.begin(), queries.end());
vector<int> ans(q);
auto it = queries.begin();
int c = 0;
while(it != queries.end() && get<0>(*it) == 0) ans[get<2>(*it)] = v[get<1>(*it)], it++;
while(1){
auto _v = v;
merge(_v.begin(), _v.begin()+n/2, _v.begin()+n/2, _v.begin()+n, v.begin());
c++;
while(it != queries.end() && get<0>(*it) <= c) ans[get<2>(*it)] = v[get<1>(*it)], it++;
if(v == _v) break;
}
while(it != queries.end()) ans[get<2>(*it)] = v[get<1>(*it)], it++;
for(int x: ans) cout << x+1 << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |