답안 #846290

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
846290 2023-09-07T13:15:25 Z vjudge1 OGLEDALA (COI15_ogledala) C++17
41 / 100
2843 ms 524288 KB
/* Author : Mychecksdead  */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 1e5+10, K = 18;


ll m, n, q, a[N], c[N];

void calc(ll n){

}

void solve(){
  cin >> m >> n >> q;
  a[0] = 0, a[n+1] = m + 1;
  for(int i = 1; i <= n; ++i) cin >> a[i];
  int cur = 1;
  set<array<ll, 3>> seg;
  for(int i = 1; i <= n + 1; ++i){
    if(a[i] - a[i - 1] - 1 > 0){
      c[cur] = a[i] - a[i - 1] - 1;
      seg.insert({c[cur], -(a[i-1]+1), a[i]-1});
      ++cur;
    }
  }
  ll x = 0;
  for(int i = 1; i <= q; ++i){
    ll b; cin >> b;
    if(b <= n){
      cout << a[b] << '\n';
      continue;
    }
    while(x < b-n-1){
      auto it = prev(seg.end());
      ll l = -(*it)[1], r = (*it)[2];
      seg.erase(it);
      seg.insert({(r-l)/2, -l, l+(r-l)/2-1});
      seg.insert({(r-l+1)/2, -(l+(r-l)/2+1), r});
      ++x;
    }
    auto it = prev(seg.end());
    ll l = -(*it)[1], r = (*it)[2];
    cout << (l+r)/2 << '\n';  
    // for(auto f: seg){
    //   cout << f[0] << ' ' << f[1] << ' ' << f[2] << '\n';
    // }
    // en;
  }
}


int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int tt = 1, aa;
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // cin >> tt;
  while(tt--){
    solve();
    en;
  }
  cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
  return 0;
}

Compilation message

ogledala.cpp: In function 'int main()':
ogledala.cpp:60:15: warning: unused variable 'aa' [-Wunused-variable]
   60 |   int tt = 1, aa;
      |               ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 42 ms 9040 KB Output is correct
4 Correct 36 ms 8016 KB Output is correct
5 Correct 105 ms 23892 KB Output is correct
6 Correct 101 ms 25420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 21328 KB Output is correct
2 Correct 85 ms 21332 KB Output is correct
3 Correct 132 ms 26636 KB Output is correct
4 Correct 118 ms 25460 KB Output is correct
5 Correct 128 ms 26964 KB Output is correct
6 Correct 135 ms 26940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2843 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -