結果
| 問題 | No.3656 Game Scores and Costs |
| コンテスト | |
| ユーザー |
QiToY
|
| 提出日時 | 2026-08-30 13:41:35 |
| 言語 | Rust (1.97.1 + proconio + num + itertools) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 2,000 ms |
| + 728µs | |
| コード長 | 1,183 bytes |
| 記録 | |
| コンパイル時間 | 898 ms |
| コンパイル使用メモリ | 185,540 KB |
| 実行使用メモリ | 7,552 KB |
| 最終ジャッジ日時 | 2026-08-30 13:42:00 |
| 合計ジャッジ時間 | 4,054 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#![allow(unused_imports)]
fn main() {
input! {
n: usize, k: usize, x: i64,
a: [i64; n],
}
let mut que = BinaryHeap::new();
let mut sum = 0;
let mut ans = -1<<60;
for a in a {
sum += a;
que.push(Reverse(a));
if que.len() > k {
let Reverse(b) = que.pop().unwrap();
sum -= b;
}
sum -= x;
chmax!(ans, sum);
}
println!("{ans}");
}
use proconio::{input, marker::*};
use itertools::{iproduct, izip, Itertools as _};
use std::{cmp::Reverse, collections::*};
#[macro_export]
macro_rules! chmax {
($a:expr, $b:expr) => {{
let tmp = $b;
if $a < tmp {
$a = tmp;
true
} else {
false
}
}};
}
#[macro_export]
macro_rules! chmin {
($a:expr, $b:expr) => {{
let tmp = $b;
if $a > tmp {
$a = tmp;
true
} else {
false
}
}};
}
#[macro_export]
/// mvec![]
macro_rules! mvec {
($val:expr; ()) => {
$val
};
($val:expr; ($size:expr $(,$rest:expr)*)) => {
vec![mvec![$val; ($($rest),*)]; $size]
};
}
QiToY