結果

問題 No.2053 12345...
ユーザー titiatitia
提出日時 2022-09-06 05:12:57
言語 Rust
(1.77.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 722 bytes
コンパイル時間 4,836 ms
コンパイル使用メモリ 142,524 KB
実行使用メモリ 5,612 KB
最終ジャッジ日時 2023-08-13 11:51:19
合計ジャッジ時間 6,771 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 4 ms
4,384 KB
testcase_04 AC 9 ms
4,508 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 9 ms
4,380 KB
testcase_07 AC 7 ms
4,380 KB
testcase_08 AC 6 ms
4,376 KB
testcase_09 AC 9 ms
4,496 KB
testcase_10 AC 13 ms
5,180 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 13 ms
5,144 KB
testcase_14 AC 5 ms
4,380 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 4 ms
4,380 KB
testcase_18 AC 14 ms
5,316 KB
testcase_19 AC 10 ms
4,452 KB
testcase_20 AC 2 ms
4,384 KB
testcase_21 AC 7 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 5 ms
4,380 KB
testcase_25 AC 12 ms
5,168 KB
testcase_26 AC 7 ms
4,380 KB
testcase_27 AC 4 ms
4,380 KB
testcase_28 AC 4 ms
4,380 KB
testcase_29 AC 9 ms
4,376 KB
testcase_30 AC 4 ms
4,376 KB
testcase_31 AC 8 ms
4,376 KB
testcase_32 AC 13 ms
5,612 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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:i64 = 0;
    let mut score:i64=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