結果

問題 No.2053 12345...
ユーザー viral8viral8
提出日時 2022-10-01 10:57:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 749 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 3,045 ms
コンパイル使用メモリ 72,784 KB
実行使用メモリ 65,048 KB
最終ジャッジ日時 2023-08-25 03:27:07
合計ジャッジ時間 20,029 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,872 KB
testcase_01 AC 121 ms
56,020 KB
testcase_02 AC 202 ms
58,304 KB
testcase_03 AC 424 ms
60,724 KB
testcase_04 AC 643 ms
63,744 KB
testcase_05 AC 369 ms
60,300 KB
testcase_06 AC 600 ms
62,344 KB
testcase_07 AC 530 ms
60,824 KB
testcase_08 AC 518 ms
60,604 KB
testcase_09 AC 626 ms
62,804 KB
testcase_10 AC 730 ms
65,048 KB
testcase_11 AC 357 ms
60,260 KB
testcase_12 AC 286 ms
60,456 KB
testcase_13 AC 731 ms
64,792 KB
testcase_14 AC 453 ms
60,528 KB
testcase_15 AC 472 ms
60,440 KB
testcase_16 AC 436 ms
60,364 KB
testcase_17 AC 377 ms
58,956 KB
testcase_18 AC 749 ms
64,600 KB
testcase_19 AC 641 ms
63,796 KB
testcase_20 AC 282 ms
60,432 KB
testcase_21 AC 520 ms
60,432 KB
testcase_22 AC 192 ms
56,336 KB
testcase_23 AC 325 ms
60,480 KB
testcase_24 AC 441 ms
60,680 KB
testcase_25 AC 728 ms
64,532 KB
testcase_26 AC 535 ms
60,648 KB
testcase_27 AC 450 ms
60,556 KB
testcase_28 AC 413 ms
60,256 KB
testcase_29 AC 602 ms
61,924 KB
testcase_30 AC 415 ms
60,872 KB
testcase_31 AC 584 ms
61,592 KB
testcase_32 AC 747 ms
64,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int now = sc.nextInt();
        long count = 1;
        long ans = 0;
        while(--N>0){
            int next = sc.nextInt();
            if(++now==next)
                ++count;
            else{
                now = next;
                ans += count*(count-1)/2;
                count = 1;
            }
        }
        System.out.println(ans+count*(count-1)/2);
    }
}
0