結果
問題 | No.1687 What the Heck? |
ユーザー | tonyu0 |
提出日時 | 2021-09-24 23:27:00 |
言語 | Rust (1.77.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 899 bytes |
コンパイル時間 | 1,387 ms |
コンパイル使用メモリ | 141,444 KB |
実行使用メモリ | 5,868 KB |
最終ジャッジ日時 | 2023-09-18 22:24:27 |
合計ジャッジ時間 | 2,623 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | WA | - |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,384 KB |
testcase_06 | AC | 1 ms
4,376 KB |
testcase_07 | AC | 4 ms
4,376 KB |
testcase_08 | AC | 6 ms
4,380 KB |
testcase_09 | WA | - |
testcase_10 | AC | 3 ms
4,376 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 11 ms
5,848 KB |
testcase_14 | AC | 11 ms
5,864 KB |
testcase_15 | AC | 12 ms
5,864 KB |
testcase_16 | AC | 11 ms
5,780 KB |
testcase_17 | AC | 1 ms
4,376 KB |
testcase_18 | AC | 12 ms
5,868 KB |
testcase_19 | AC | 1 ms
4,380 KB |
ソースコード
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 n: usize = itr.next().unwrap().parse().unwrap(); let a: Vec<usize> = (0..n) .map(|_| itr.next().unwrap().parse::<usize>().unwrap() - 1) .collect(); let mut used = vec![false; n + 1]; let mut ans = 0; for i in (0..n).rev() { let mut j = a[i] + 1; while j < n && used[j] { j += 1; } if j != n { used[j] = true; ans += i + 1; } else if !used[a[i]] { used[a[i]] = true; } else { for k in 0..n { if !used[k] { used[k] = true; break; } } ans -= i + 1; } } println!("{}", ans); }