답안 #846193

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
846193 2023-09-07T12:18:57 Z vjudge1 OGLEDALA (COI15_ogledala) C++
41 / 100
67 ms 21880 KB
#include <bits/stdc++.h>
using namespace std;
#pragma optimize "DostSeferoğlu"
#pragma GCC optimize("unroll-loops,Ofast")
#pragma GCC target("avx2,tune=native")
#define int long long
#define pii pair<int,int>
#define bg begin
#define vi vector<int>
#define endl '\n'
#define vvi vector<vi> 
#define vp vector<pii>
#define sp << " " << 
#define ff first
#define ss second
#define brake {cout << "OK\n";return;}
#define debug(x) {cout << #x << ": "; for (auto it : x) cout << it << " ";cout << endl;}
#define FF(xxx,sss,yyy) for (int xxx=sss;xxx<=yyy;++xxx)
#define F(xx,yy) for (int xx=1;xx<=yy;++xx)
#define pb push_back 
const int inf = 1e18;
const int MOD = 998244353;   
const int N = 3e5+1;

class Compare {
    public:
       bool operator()(pair<int,pii> a, pair<int,pii> b){
           if(a.ff == b.ff)return a.ss.ff > b.ss.ff;
           return a.ff < b.ff;
        }
}; 

void solve() {
    int n,m,q;
    cin >> n >> m >> q;
    priority_queue<pair<int,pii>,vector<pair<int,pii>>,Compare> pq;
    int prev = 0;
    vi ans(min(300001LL,n+1),0);
    int c = 1;
    for (int i=1;i<=m;i++) {
        cin >> ans[i];
        pq.push({(ans[i]-1)-(prev+1)+1,{prev+1,ans[i]-1}});
        prev = ans[i];
    }
    pq.push({n-prev,{prev+1,n}});
    for (int i=m+1;i<=min(300000LL,n);i++) {
        auto f = pq.top();
        pq.pop();
        int l = f.ss.first;
        int r = f.ss.ss;
        int mid = (l+r)/2;
        if (l<=mid-1) pq.push({mid-l,{l,mid-1}});
        if(mid+1<=r) pq.push({r-mid,{mid+1,r}});
        ans[i] = mid;
    }
    while (q--) {
        int ind;
        cin >> ind;
        cout << ans[ind] << endl;   
    }
}                 






signed main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);
    #ifdef Local
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);  
    #endif
    int t = 1;
    //cin >> t; 
    while (t --> 0) solve();
}

Compilation message

ogledala.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    3 | #pragma optimize "DostSeferoğlu"
      | 
ogledala.cpp: In function 'void solve()':
ogledala.cpp:39:9: warning: unused variable 'c' [-Wunused-variable]
   39 |     int c = 1;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 22 ms 2736 KB Output is correct
4 Correct 25 ms 2852 KB Output is correct
5 Correct 54 ms 9672 KB Output is correct
6 Correct 49 ms 9676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 15036 KB Output is correct
2 Correct 47 ms 15304 KB Output is correct
3 Correct 61 ms 17852 KB Output is correct
4 Correct 67 ms 17592 KB Output is correct
5 Correct 61 ms 17340 KB Output is correct
6 Correct 62 ms 17344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 57 ms 21880 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -