結果

問題 No.1687 What the Heck?
ユーザー phsplsphspls
提出日時 2022-10-18 15:29:43
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 665 bytes
コンパイル時間 4,766 ms
コンパイル使用メモリ 140,608 KB
実行使用メモリ 6,308 KB
最終ジャッジ日時 2023-09-11 08:49:22
合計ジャッジ時間 6,251 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 4 ms
4,384 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 13 ms
6,272 KB
testcase_13 AC 13 ms
6,204 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut val2idx = vec![n; n+1];
    for i in 0..n {
        val2idx[a[i]] = i+1;
    }
    let mut result = 0usize;
    let mut exp = a.iter().sum::<usize>();
    for i in (1..=n).rev() {
        let score = val2idx[i];
        if exp > 2*score {
            result = result.max(exp - 2*score);
        }
        exp -= i;
    }
    println!("{}", result);
}
0