結果
| 問題 |
No.1687 What the Heck?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-18 14:02:50 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 714 bytes |
| コンパイル時間 | 12,991 ms |
| コンパイル使用メモリ | 377,864 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 22:18:25 |
| 合計ジャッジ時間 | 14,366 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 WA * 10 |
ソースコード
fn main() {
let mut n = String::new();
std::io::stdin().read_line(&mut n).ok();
let n: usize = n.trim().parse().unwrap();
let mut p = String::new();
std::io::stdin().read_line(&mut p).ok();
let mut p: Vec<usize> = p.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
if n < 4 {
if (0..n).filter(|&i| p[i] == i+1).count() == n {
println!("0");
return;
} else {
while *p.last().unwrap() == p.len() {
p.pop();
}
}
}
let n = p.len();
let summary = p.iter().sum::<usize>();
let idx = (0..n).filter(|&i| p[i] == n).nth(0).unwrap() + 1;
println!("{}", summary - 2*idx);
}