結果
| 問題 | No.3656 Game Scores and Costs |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-31 08:04:30 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 63 ms / 2,000 ms |
| + 934µs | |
| コード長 | 486 bytes |
| 記録 | |
| コンパイル時間 | 2,306 ms |
| コンパイル使用メモリ | 196,084 KB |
| 実行使用メモリ | 9,784 KB |
| 最終ジャッジ日時 | 2026-08-31 08:04:40 |
| 合計ジャッジ時間 | 6,557 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main(void){
ll n, k, x; cin >> n >> k >> x;
vector<ll> a(n);
for(auto&x:a) cin >> x;
priority_queue<ll, vector<ll>, greater<ll>> pri;
ll now=0, ans=-1e18;
for(int i=0; i<n; i++){
now+=a[i]; pri.push(a[i]);
if(pri.size()>k) now-=pri.top(), pri.pop();
ans=max(ans, now-x*(i+1));
}
cout << ans << endl;
return 0;
}