답안 #960342

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
960342 2024-04-10T09:32:29 Z firewater Abracadabra (CEOI22_abracadabra) C++14
0 / 100
3000 ms 16508 KB
#include<bits/stdc++.h>
#define ll long long
#define fs first
#define sn second
#define N 202400
using namespace std;
int n,m,x,y,z,now,sav,l,r,v[N],a[N],b[N],nx[N],sz[N],ans[N],p[N];
tuple<int,int,int>q[N];
stack<int>st;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i){
        scanf("%d",&a[i]);
        v[a[i]]=i;
    }
    for(int i=1;i<=m;++i){
        scanf("%d%d",&x,&y);
        q[i]=tie(x,y,i);
    }
    sort(q+1,q+1+m);
    now=1;
    for(int i=0;1;++i){
        while(now<=m&&get<0>(q[now])==i){
            tie(x,y,z)=q[now];
            ans[z]=a[y];
            now++;
        }
        if(now>m)break;
        l=1;
        r=n/2+1;
        for(int i=1;i<=n;++i){
            if((r>n)||(a[l]<a[r]&&l<=n/2))b[i]=a[l++];
            else b[i]=a[r++];
        }
        for(int i=1;i<=n;++i)
            a[i]=b[i];
    }
    for(int i=1;i<=m;++i)
        printf("%d\n",ans[i]);
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
Main.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~
Main.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d%d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3055 ms 12452 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3065 ms 16508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3033 ms 9052 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3055 ms 12452 KB Time limit exceeded
2 Halted 0 ms 0 KB -