結果

問題 No.2053 12345...
ユーザー tentententen
提出日時 2024-04-30 13:09:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 280 ms / 2,000 ms
コード長 1,457 bytes
コンパイル時間 2,465 ms
コンパイル使用メモリ 78,740 KB
実行使用メモリ 49,672 KB
最終ジャッジ日時 2024-11-20 08:17:03
合計ジャッジ時間 10,384 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
36,696 KB
testcase_01 AC 55 ms
36,784 KB
testcase_02 AC 91 ms
38,512 KB
testcase_03 AC 191 ms
44,308 KB
testcase_04 AC 240 ms
46,224 KB
testcase_05 AC 160 ms
42,780 KB
testcase_06 AC 248 ms
45,956 KB
testcase_07 AC 196 ms
43,964 KB
testcase_08 AC 190 ms
43,988 KB
testcase_09 AC 250 ms
46,056 KB
testcase_10 AC 271 ms
49,276 KB
testcase_11 AC 139 ms
41,260 KB
testcase_12 AC 127 ms
40,388 KB
testcase_13 AC 266 ms
47,336 KB
testcase_14 AC 207 ms
44,708 KB
testcase_15 AC 188 ms
44,384 KB
testcase_16 AC 189 ms
44,220 KB
testcase_17 AC 149 ms
42,072 KB
testcase_18 AC 273 ms
49,672 KB
testcase_19 AC 248 ms
46,128 KB
testcase_20 AC 120 ms
40,032 KB
testcase_21 AC 191 ms
43,884 KB
testcase_22 AC 68 ms
38,156 KB
testcase_23 AC 136 ms
40,624 KB
testcase_24 AC 164 ms
43,392 KB
testcase_25 AC 277 ms
49,600 KB
testcase_26 AC 198 ms
43,996 KB
testcase_27 AC 171 ms
43,212 KB
testcase_28 AC 186 ms
43,580 KB
testcase_29 AC 243 ms
46,484 KB
testcase_30 AC 166 ms
42,964 KB
testcase_31 AC 237 ms
46,040 KB
testcase_32 AC 280 ms
49,652 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