結果
| 問題 | No.1338 Giant Class |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-15 21:48:59 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 140 ms / 2,000 ms |
| コード長 | 850 bytes |
| 記録 | |
| コンパイル時間 | 13,879 ms |
| コンパイル使用メモリ | 401,100 KB |
| 実行使用メモリ | 7,248 KB |
| 最終ジャッジ日時 | 2024-11-26 14:06:13 |
| 合計ジャッジ時間 | 15,595 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
ソースコード
use std::collections::HashMap;
use std::io::*;
fn main() {
let mut s: String = String::new();
std::io::stdin().read_to_string(&mut s).ok();
let mut itr = s.trim().split_whitespace();
let h: usize = itr.next().unwrap().parse().unwrap();
let w: usize = itr.next().unwrap().parse().unwrap();
let q: usize = itr.next().unwrap().parse().unwrap();
let mut ans = h * w;
let mut mp = HashMap::new();
for _ in 0..q {
let y = itr.next().unwrap().parse::<usize>().unwrap() - 1;
let x = itr.next().unwrap().parse::<usize>().unwrap() - 1;
if let Some(cur_y) = mp.get_mut(&x) {
if *cur_y > y {
ans -= *cur_y - y;
*cur_y = y;
}
} else {
mp.insert(x, y);
ans -= h - y;
}
println!("{}", ans);
}
}