結果
| 問題 | No.3656 Game Scores and Costs |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-30 13:48:45 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 582 bytes |
| 記録 | |
| コンパイル時間 | 1,124 ms |
| コンパイル使用メモリ | 178,064 KB |
| 実行使用メモリ | 14,464 KB |
| 最終ジャッジ日時 | 2026-08-30 13:49:00 |
| 合計ジャッジ時間 | 4,344 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 WA * 8 |
ソースコード
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main() {
long long n, k, x;
cin >> n >> k >> x;
vector<long long> a(n);
for (long long &l : a) {
cin >> l;
}
set<long long> s;
long long score = 0, ans = -1e18;
for (int i = 0; i < n; i++) {
s.insert(a[i]);
score += a[i];
score -= x;
if (s.size() > k) {
score -= *s.begin();
s.erase(s.begin());
}
// cout << score << endl;
ans = max(score, ans);
}
cout << ans << endl;
}