結果
問題 | No.77 レンガのピラミッド |
ユーザー | tonyu0 |
提出日時 | 2020-03-29 00:34:36 |
言語 | Rust (1.77.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,053 bytes |
コンパイル時間 | 1,891 ms |
コンパイル使用メモリ | 147,976 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-08-30 18:22:46 |
合計ジャッジ時間 | 2,226 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | RE | - |
testcase_15 | WA | - |
testcase_16 | RE | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | WA | - |
testcase_24 | AC | 1 ms
4,376 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<i32> = (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let mut ans = 1 << 30; let center = n / 2; for i in 1..(n / 2 + 2) as i32 { let mut diff = a[center] - i; let mut cnt = diff.abs(); for j in 1..n / 2 + 1 { let need = i - j as i32; if need <= 0 { diff += a[center + j] + a[center - j]; cnt += a[center + j] + a[center - j]; continue; } diff += a[center + j] - need; diff += a[center - j] - need; cnt += (a[center + j] - need).abs(); cnt += (a[center - j] - need).abs(); } if diff >= 0 { ans = std::cmp::min(ans, (cnt - diff) / 2 + diff); } } println!("{}", ans); }