結果

問題 No.1338 Giant Class
ユーザー phsplsphspls
提出日時 2022-11-19 22:11:43
言語 Rust
(1.77.0)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 908 bytes
コンパイル時間 1,647 ms
コンパイル使用メモリ 189,072 KB
実行使用メモリ 6,876 KB
最終ジャッジ日時 2023-10-21 02:23:27
合計ジャッジ時間 5,544 ms
ジャッジサーバーID
(参考情報)
judge9 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 145 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 102 ms
6,296 KB
testcase_07 AC 146 ms
6,712 KB
testcase_08 AC 96 ms
6,228 KB
testcase_09 AC 87 ms
4,576 KB
testcase_10 AC 159 ms
6,864 KB
testcase_11 AC 16 ms
4,348 KB
testcase_12 AC 113 ms
4,844 KB
testcase_13 AC 91 ms
4,604 KB
testcase_14 AC 25 ms
4,348 KB
testcase_15 AC 37 ms
4,348 KB
testcase_16 AC 13 ms
4,348 KB
testcase_17 AC 91 ms
4,608 KB
testcase_18 AC 24 ms
4,348 KB
testcase_19 AC 44 ms
4,348 KB
testcase_20 AC 162 ms
6,876 KB
testcase_21 AC 161 ms
6,876 KB
testcase_22 AC 162 ms
6,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::HashMap;


fn main() {
    let mut hwq = String::new();
    std::io::stdin().read_line(&mut hwq).ok();
    let hwq: Vec<usize> = hwq.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let h = hwq[0];
    let w = hwq[1];
    let q = hwq[2];
    let queries = (0..q).map(|_| {
        let mut temp = String::new();
        std::io::stdin().read_line(&mut temp).ok();
        let temp: Vec<usize> = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
        (temp[0]-1, temp[1]-1)
    })
    .collect::<Vec<_>>();

    let mut mins = HashMap::new();
    let mut summary = h*w;
    for &(y, x) in queries.iter() {
        let val = *mins.get(&x).unwrap_or(&h);
        if val < y {
            println!("{}", summary);
        } else {
            summary -= val - y;
            mins.insert(x, y);
            println!("{}", summary);
        }
    }
}
0