이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int maxn=1000+10;
int n,q;
int all[maxn][maxn];
void solve(int ind){
int i=1,j=n/2+1;
int z=1;
while(i<=(n/2)&&j<=n){
if(all[ind-1][i]<all[ind-1][j]){
all[ind][z]=all[ind-1][i];
z++;
i++;
}
else{
all[ind][z]=all[ind-1][j];
j++;
z++;
}
}
while(i<=(n/2)){
all[ind][z]=all[ind-1][i];
i++;
z++;
}
while(j<=n){
all[ind][z]=all[ind-1][j];
j++;
z++;
}
return ;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>q;
for(int i=1;i<=n;i++){
cin>>all[0][i];
}
for(int j=1;j<=n;j++){
solve(j);
}
for(int i=0;i<q;i++){
int u,v;
cin>>u>>v;
u=min(u,n);
cout<<all[u][v]<<"\n";
}
}
# | 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... |