結果

問題 No.3656 Game Scores and Costs
コンテスト
ユーザー てせ / ctes
提出日時 2026-08-30 14:01:38
言語 C++17
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 856 ms / 2,000 ms
+ 918µs
コード長 536 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,188 ms
コンパイル使用メモリ 215,464 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2026-08-30 14:02:07
合計ジャッジ時間 18,068 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main(){
  ll n, k, x; cin >> n >> k >> x;
  vector<ll> a(n);
  for(ll i=0; i<n; i++) cin >> a[i];

  priority_queue<ll, vector<ll>, greater<ll>> pq;

  ll ans = -2147483647;
  ll csum = 0;
  for(ll i=0; i<n; i++){
    csum += a[i];
    pq.push(a[i]);

    while(pq.size() > k){
      csum -= pq.top();
      pq.pop(); 
    }
    ll f = csum - (x * (i+1));
    cerr << csum << " " << x*i << " " << f << endl;
    ans = max(ans, f);
  }

  cout << ans << endl;
}

0