結果
| 問題 | No.3656 Game Scores and Costs |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-02 17:35:52 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 64 ms / 2,000 ms |
| + 1µs | |
| コード長 | 580 bytes |
| 記録 | |
| コンパイル時間 | 3,947 ms |
| コンパイル使用メモリ | 357,372 KB |
| 実行使用メモリ | 9,748 KB |
| 最終ジャッジ日時 | 2026-09-02 17:36:01 |
| 合計ジャッジ時間 | 6,492 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
int main()
{
int n, k;
ll x;
cin >> n >> k >> x;
vector<ll> a(n);
rep(i, n) cin >> a[i];
ll ans = LLONG_MIN / 2, sum = 0;
priority_queue<ll, vector<ll>, greater<ll>> q;
rep(i, n)
{
q.push(a[i]);
sum += a[i];
if (k < q.size())
{
sum -= q.top();
q.pop();
}
if (ans < sum - x * (i + 1))
ans = sum - x * (i + 1);
}
cout << ans << endl;
}