Yandex.Algorithm 2020 Qualification round D問題 - A reliable counter

Source

Yandex.Algorithm 2020 Qualification round
問題文

問題概要

省略

解法

省略

cLayversion 20201031-1)のコード

C++に変換後のコードはこちら

int N, K, R, A;
multiset<ll> a, b;
ll s, t, u;
int ress; ll res[2d5];
{
  rd(N,K,R);
  rep(K){
    rd(A);
    a.insert(A);
    s += A;
  }
  rep(N-K) b.insert(rd_ll());

  rep(R){
    t = s;
    s -= popFirst(a);
    
    a.insert(t);
    s += t;

    if(b.size() && getLast(a) > getFirst(b)){
      t = popLast(a);
      u = popFirst(b);
      a.insert(u);
      b.insert(t);
      s += u - t;
    }
  }

  for(ll x : a) res[ress++] = x;
  for(ll x : b) res[ress++] = x;
  wt(res(ress));
}

Current time: 2024年04月27日06時06分51秒
Last modified: 2020年10月31日02時37分44秒 (by laycrs)
Tags: Competitive_Programming_Incomplete Yandex_Algorithm
トップページに戻る

Logged in as: unknown user (not login)

ログイン: