結果

問題 No.3656 Game Scores and Costs
コンテスト
ユーザー rinrion
提出日時 2026-08-30 21:54:04
言語 C++14
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 23 ms / 2,000 ms
+ 821µs
コード長 1,120 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,417 ms
コンパイル使用メモリ 250,056 KB
実行使用メモリ 9,784 KB
最終ジャッジ日時 2026-08-30 21:54:22
合計ジャッジ時間 6,054 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
#define rep(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define repr(i, s, n) for (int i = (s); i >= (int)(n); --i)
#define sz(x) ((int)(x).size())
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
auto _ = []{ios::sync_with_stdio(false); cin.tie(nullptr); return 0;}();
const int INFI = 1 << 30;
const ll INFL = 1LL << 62;

int main() {
	ll n, k, x;
	cin >> n >> k >> x;
	vl a (n);
	rep(i, 0, n){
		cin >> a[i];
	}
	ll mx=-INFL;
	priority_queue<ll, vector<ll>, greater<ll>>q;
	ll sm=0;
	rep (i, 0, n){
		sm+=a[i];
		q.push(a[i]);
		if(sz(q)>k){
			sm-=q.top();
			q.pop();
		}
		chmax(mx,sm-x*(i+1)) << '\n';
	}
	cout << mx << '\n';
	

	return 0;
}
0