結果
| 問題 | No.3656 Game Scores and Costs |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2026-08-31 09:44:17 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 58 ms / 2,000 ms |
| + 721µs | |
| コード長 | 773 bytes |
| 記録 | |
| コンパイル時間 | 587 ms |
| コンパイル使用メモリ | 70,000 KB |
| 実行使用メモリ | 14,208 KB |
| 最終ジャッジ日時 | 2026-08-31 09:44:24 |
| 合計ジャッジ時間 | 4,118 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 3656.cc: No.3656 Game Scores and Costs - yukicoder
*/
#include<cstdio>
#include<set>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 200000;
const long long LINF = 1LL << 60;
/* typedef */
using ll = long long;
using msi = multiset<int>;
/* global variables */
int as[MAX_N];
/* subroutines */
/* main */
int main() {
int n, k, x;
scanf("%d%d%d", &n, &k, &x);
for (int i = 0; i < n; i++) scanf("%d", as + i);
ll sum = 0, maxf = -LINF;
msi q;
for (int i = 0; i < n; i++) {
sum += as[i];
q.insert(as[i]);
while ((int)q.size() > k) sum -= *q.begin(), q.erase(q.begin());
ll f = sum - (ll)x * (i + 1);
maxf = max(maxf, f);
}
printf("%lld\n", maxf);
return 0;
}
tnakao0123