답안 #846304

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
846304 2023-09-07T13:21:06 Z vjudge1 OGLEDALA (COI15_ogledala) C++17
0 / 100
259 ms 524288 KB
#ifndef Local
    #pragma GCC optimize("O3,unroll-loops")
    #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define int long long
#define pb push_back
#define lim 300000
#define till 40001
// # of primes till 1e6 = 7e4
using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
using pii = array<int,2>;

const int mod=1000000007ll;

struct comp{
    bool operator() (pii a,pii b){
        if(a[1]-a[0]>b[1]-b[0]){
            return 0;
        }
        if(a[1]-a[0]<b[1]-b[0]){
            return 1;
        }
        return a[0]>b[0];
    }
};

void solve(){
    int n,m,q;
    cin>>m>>n>>q;
    int a[n];
    int lad[m];
    for(int i=0;i<n;i++){
        cin>>a[i];
        lad[i]=a[i];
    }
    /*
    for(int i=0;i<m;i++){
        cerr<<lad[i]<<" ";
    }cerr<<"\n";
    */
    sort(a,a+n);
    priority_queue<pii,vector<pii>,comp>all;
    if(a[0]!=1)all.push({1,a[0]-1});
    for(int i=0;i<n-1;i++){
        //cerr<<a[i]+1<<" "<<a[i+1]-1<<"\n";
        if(a[i]+1!=a[i+1]-1)all.push({a[i]+1,a[i+1]-1});
    }
    if(a[n-1]+1!=m)all.push({a[n-1]+1,m});
    int next=n;
    while(all.size()&&next<m){
        pii cur=all.top();
        all.pop();
        if(next<100)cerr<<cur[0]<<" "<<(cur[1]+cur[0]+1)/2<<" "<<cur[1]<<"\n";
        lad[next++]=(cur[1]+cur[0]+1)/2;
        if(cur[0]<=(cur[1]+cur[0]+1)/2-1)all.push({cur[0],(cur[1]+cur[0]+1)/2-1});
        if(cur[1]>=(cur[1]+cur[0]+1)/2+1)all.push({(cur[1]+cur[0]+1)/2+1,cur[1]});
    }
    /*
    for(int i=0;i<m;i++){
        cerr<<lad[i]<<" ";
    }cerr<<"\n";
    */
    for(int i=0;i<q;i++){
        int tem;
        cin>>tem;
        tem--;
        cout<<lad[tem]<<"\n";
    }
}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
#ifdef Local  
#ifndef INTERACTIVE
    freopen("in","r",stdin);
#endif
    freopen("out","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while (t--)
    {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 259 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 252 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -