This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define N 1003
int main(){
ios_base::sync_with_stdio(0);
int n, q;
cin >> n >> q;
vector<int> a(n), ans;
for(int i=0; i<n; i++)
cin >> a[i];
vector<pair<int, int>> qs(q);
for(int i=0; i<q; i++){
cin >> qs[i].first;
cin >> qs[i].second;
}
int qt = qs[0].first;
if(qt >= N)
qt = N - 1;
for(int cnt=1; cnt<N; cnt++){
int i = 0;
int j = n/2;
vector<int> v = a;
int k = 0;
while(i < n/2 && j < n){
if(v[i] < v[j]){
a[k] = v[i];
k++, i++;
}
else{
a[k] = v[j];
k++, j++;
}
}
while(i < n/2){
a[k] = v[i];
k++, i++;
}
while(j < n/2){
a[k] = v[j];
k++, j++;
}
if(qt == cnt)
ans = a;
}
for(int i=0; i<q; i++){
int ind = qs[i].second;
cout << ans[ind-1] << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |