結果

問題 No.2053 12345...
ユーザー tentententen
提出日時 2024-04-30 13:09:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 1,457 bytes
コンパイル時間 2,348 ms
コンパイル使用メモリ 78,840 KB
実行使用メモリ 60,896 KB
最終ジャッジ日時 2024-04-30 13:09:12
合計ジャッジ時間 9,971 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
50,280 KB
testcase_01 AC 54 ms
50,308 KB
testcase_02 AC 97 ms
51,708 KB
testcase_03 AC 149 ms
54,960 KB
testcase_04 AC 248 ms
57,604 KB
testcase_05 AC 153 ms
54,604 KB
testcase_06 AC 239 ms
57,544 KB
testcase_07 AC 200 ms
55,000 KB
testcase_08 AC 191 ms
54,900 KB
testcase_09 AC 248 ms
57,596 KB
testcase_10 AC 272 ms
60,896 KB
testcase_11 AC 144 ms
54,216 KB
testcase_12 AC 132 ms
52,280 KB
testcase_13 AC 275 ms
58,980 KB
testcase_14 AC 188 ms
54,812 KB
testcase_15 AC 164 ms
54,448 KB
testcase_16 AC 158 ms
54,764 KB
testcase_17 AC 161 ms
54,544 KB
testcase_18 AC 276 ms
60,844 KB
testcase_19 AC 243 ms
57,748 KB
testcase_20 AC 121 ms
52,136 KB
testcase_21 AC 191 ms
55,016 KB
testcase_22 AC 75 ms
51,364 KB
testcase_23 AC 144 ms
52,256 KB
testcase_24 AC 158 ms
54,560 KB
testcase_25 AC 275 ms
60,768 KB
testcase_26 AC 201 ms
55,596 KB
testcase_27 AC 170 ms
54,804 KB
testcase_28 AC 169 ms
55,352 KB
testcase_29 AC 240 ms
57,700 KB
testcase_30 AC 169 ms
54,932 KB
testcase_31 AC 232 ms
57,480 KB
testcase_32 AC 267 ms
60,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int prev = sc.nextInt();
        int count = 1;
        long ans = 0;
        while (n-- > 1) {
            int x = sc.nextInt();
            if (x == prev + 1) {
                ans += count;
                count++;
            } else {
                count = 1;
            }
            prev = x;
        }
        System.out.println(ans);
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}
0