結果
| 問題 | No.3656 Game Scores and Costs |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2026-08-30 13:43:29 |
| 言語 | Rust (1.97.1 + proconio + num + itertools) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 2,000 ms |
| + 634µs | |
| コード長 | 492 bytes |
| 記録 | |
| コンパイル時間 | 658 ms |
| コンパイル使用メモリ | 182,764 KB |
| 実行使用メモリ | 7,424 KB |
| 最終ジャッジ日時 | 2026-08-30 13:43:38 |
| 合計ジャッジ時間 | 3,251 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
use std::{cmp::Reverse, collections::BinaryHeap};
use proconio::input;
fn solve() -> i64 {
input! {
n: usize,
k: usize,
x: i64,
a: [i64; n],
}
let mut q = BinaryHeap::new();
let mut s = 0;
let mut ans = i64::MIN;
for (i, &ai) in a.iter().enumerate() {
q.push(Reverse(ai));
s += ai;
if q.len() > k {
s -= q.pop().unwrap().0;
}
ans = ans.max(s - (i as i64 + 1) * x);
}
ans
}
fn main() {
let ans = solve();
println!("{}", ans);
}