답안 #846286

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
846286 2023-09-07T13:12:36 Z vjudge1 OGLEDALA (COI15_ogledala) C++17
0 / 100
2973 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;
    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:56:15: warning: unused variable 'aa' [-Wunused-variable]
   56 |   int tt = 1, aa;
      |               ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 21328 KB Output is correct
2 Incorrect 94 ms 21356 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2973 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -