結果

問題 No.3424 Shooting Game
コンテスト
ユーザー elphe
提出日時 2026-01-11 14:51:49
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 41 ms / 2,000 ms
+ 478µs
コード長 963 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,603 ms
コンパイル使用メモリ 205,724 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2026-07-20 06:33:47
合計ジャッジ時間 7,051 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        t: u32,
        targets: [(u32, u32, u32); n],
    }

    println!("{}", output(solve(t, targets)));
}

fn solve(t: u32, mut targets: Vec<(u32, u32, u32)>) -> u64 {
    let mut dp = [0; 200_002];
    let mut pq = std::collections::BinaryHeap::with_capacity(targets.len());
    targets.sort_unstable_by_key(|&(l, _, _)| l);
    let mut targets = targets.into_iter().peekable();
    for time in 0..=200_000 {
        while let Some(&(l, r, p)) = targets.peek() && l == time {
            targets.next();
            pq.push((p, r));
        }
        while let Some(&(_, r)) = pq.peek() && time > r {
            pq.pop();
        }
        
        let p = pq.peek().unwrap_or(&(0, u32::MAX)).0;
        dp[(time + 1) as usize] = dp[time as usize].max(dp[time.saturating_sub(t - 1) as usize] + p as u64);
    }
    dp[200_001]
}

fn output(ans: u64) -> u64 {
    ans
}
0