結果

問題 No.2053 12345...
ユーザー titiatitia
提出日時 2022-09-06 05:07:23
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 712 bytes
コンパイル時間 1,109 ms
コンパイル使用メモリ 149,456 KB
実行使用メモリ 5,676 KB
最終ジャッジ日時 2023-08-13 11:45:48
合計ジャッジ時間 4,625 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 10 ms
4,496 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 7 ms
4,380 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 14 ms
5,164 KB
testcase_14 AC 5 ms
4,380 KB
testcase_15 AC 5 ms
4,380 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 4 ms
4,380 KB
testcase_18 AC 15 ms
5,348 KB
testcase_19 AC 11 ms
4,540 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 7 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 4 ms
4,380 KB
testcase_29 WA -
testcase_30 AC 4 ms
4,384 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable `A` should have a snake case name
 --> Main.rs:8:9
  |
8 |     let A: Vec<i64> = {
  |         ^ help: convert the identifier to snake case: `a`
  |
  = note: `#[warn(non_snake_case)]` on by default

warning: 1 warning emitted

ソースコード

diff #

fn main() {
    let n: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let A: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let mut ans=0;
    let mut score=1;

    for i in 1..n{
        if A[i]==A[i-1]+1{
            score+=1;
        }
        else if score>1{
            ans+=score*(score-1)/2;
            score=1;
        }
    }

    if score>1{
        ans+=score*(score-1)/2;
    }

    println!("{}",ans);



}
0