結果
| 問題 | No.3656 Game Scores and Costs |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-08-30 14:47:48 |
| 言語 | Rust (1.97.1 + proconio + num + itertools) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 2,000 ms |
| + 953µs | |
| コード長 | 1,016 bytes |
| 記録 | |
| コンパイル時間 | 657 ms |
| コンパイル使用メモリ | 189,504 KB |
| 実行使用メモリ | 7,424 KB |
| 最終ジャッジ日時 | 2026-08-30 14:47:54 |
| 合計ジャッジ時間 | 3,095 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#![allow(non_snake_case, unused_imports)]
use std::cmp::Reverse;
use std::collections::{BinaryHeap, HashMap, HashSet};
use proconio::{input, marker::Usize1, marker::Chars};
use itertools::Itertools;
#[allow(unused_macros)]
macro_rules! d {
( $( $x:expr ),* $(,)? ) => {
eprintln!(
concat!( $( stringify!($x), "={:?} " ),* ),
$( $x ),*
);
};
}
#[allow(dead_code)]
fn yn(b: bool) -> &'static str {
if b { "Yes" } else { "No" }
}
fn main() {
input! {
N: usize,
K: usize,
X: i64,
A: [i64; N],
}
let mut q = BinaryHeap::<Reverse<i64>>::new();
let mut tot = 0;
let mut ans = i64::MIN;
for (i, &a) in A.iter().enumerate() {
q.push(Reverse(a));
tot += a;
if q.len() > K {
if let Some(Reverse(x)) = q.pop() {
tot -= x;
}
}
let score = tot - X * (i+1) as i64;
ans = ans.max(score);
}
println!("{}", ans);
}
norioc