/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,q;
cin>>n>>q;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
vector<int>v[n+2];
for(int i=0;i<n;i++){
v[0].push_back(arr[i]);
}
for(int j=1;j<=n;j++){
int prvi=0;
int drugi=n/2;
int t1=0;
while(t1==0){
if(prvi<n/2 and drugi<n){
if(v[j-1][prvi]>v[j-1][drugi]){
v[j].push_back(v[j-1][drugi]);
drugi++;
}else{
v[j].push_back(v[j-1][prvi]);
prvi++;
}
}else{
if(prvi>=n/2){
if(drugi>=n){
t1++;
break;
}else{
v[j].push_back(v[j-1][drugi]);
drugi++;
}
}else{
v[j].push_back(v[j-1][prvi]);
prvi++;
}
}
}
}
while(q--){
int t,i;
cin>>t>>i;
i--;
if(t<=n){
cout<<v[t][i]<<endl;
}else{
cout<<i+1<<endl;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1504 ms |
12416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
617 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
575 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1504 ms |
12416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |