結果

問題 No.3656 Game Scores and Costs
コンテスト
ユーザー ウニ亭
提出日時 2026-08-30 13:57:28
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,032 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 6,251 ms
コンパイル使用メモリ 388,540 KB
実行使用メモリ 14,464 KB
最終ジャッジ日時 2026-08-30 13:57:54
合計ジャッジ時間 11,981 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using mint = modint998244353;
ll MOD=998244353;
#define all(x) x.begin(), x.end()
#define rep(i, n) for(ll i = 0; (i) < (n); (i)++)
template<class T>
auto comp_idx(const T* ptr){
  return [ptr](auto l_idx, auto r_idx){
    return ptr[l_idx] < ptr[r_idx];
  };
}
template<class T>
vector<ll> IndexSort(T vec){
    vector<ll> ind(vec.size());
    iota(all(ind), 0);
    sort(all(ind), comp_idx(vec.data()));
    return ind;
}
void yn(bool flag){
  string ans = (flag) ? "Yes" : "No";
  cout<<ans<<endl;
}

int main(){
  ll n, k, x; cin>>n>>k>>x;
  vector<ll> A(n);
  rep(i, n){
    cin>>A[i];
  }
  multiset<ll> mem;
  ll ans=A[0]-x;
  ll now=A[0];
  mem.insert(A[0]);
  rep(i, n-1){
    now+=A[i+1];
    mem.insert(A[i+1]);
    if(mem.size()>k){
      now-=*mem.begin();
      mem.erase(mem.begin());
    }
    //ans=max(ans, now-x*(i+2));
    cout<<ans<<endl;
  }
  cout<<ans<<endl;
}
0