結果

問題 No.1505 Zero-Product Ranges
ユーザー tentententen
提出日時 2021-05-17 09:04:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 210 ms / 2,000 ms
コード長 1,095 bytes
コンパイル時間 2,323 ms
コンパイル使用メモリ 74,652 KB
実行使用メモリ 44,780 KB
最終ジャッジ日時 2024-04-15 21:58:14
合計ジャッジ時間 11,258 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
36,692 KB
testcase_01 AC 49 ms
36,912 KB
testcase_02 AC 49 ms
36,564 KB
testcase_03 AC 202 ms
44,752 KB
testcase_04 AC 210 ms
44,728 KB
testcase_05 AC 145 ms
42,948 KB
testcase_06 AC 157 ms
42,960 KB
testcase_07 AC 130 ms
41,504 KB
testcase_08 AC 141 ms
43,036 KB
testcase_09 AC 128 ms
42,612 KB
testcase_10 AC 141 ms
42,320 KB
testcase_11 AC 138 ms
43,176 KB
testcase_12 AC 118 ms
41,732 KB
testcase_13 AC 157 ms
43,524 KB
testcase_14 AC 151 ms
43,312 KB
testcase_15 AC 200 ms
44,668 KB
testcase_16 AC 202 ms
44,780 KB
testcase_17 AC 207 ms
44,656 KB
testcase_18 AC 204 ms
44,268 KB
testcase_19 AC 49 ms
36,696 KB
testcase_20 AC 50 ms
36,636 KB
testcase_21 AC 50 ms
37,136 KB
testcase_22 AC 200 ms
44,352 KB
testcase_23 AC 195 ms
44,628 KB
testcase_24 AC 194 ms
44,632 KB
testcase_25 AC 189 ms
44,620 KB
testcase_26 AC 202 ms
44,636 KB
testcase_27 AC 189 ms
43,952 KB
testcase_28 AC 190 ms
44,664 KB
testcase_29 AC 202 ms
44,752 KB
testcase_30 AC 196 ms
44,612 KB
testcase_31 AC 184 ms
44,588 KB
testcase_32 AC 152 ms
43,016 KB
testcase_33 AC 172 ms
43,084 KB
testcase_34 AC 150 ms
43,336 KB
testcase_35 AC 164 ms
43,256 KB
testcase_36 AC 134 ms
42,984 KB
testcase_37 AC 171 ms
44,364 KB
testcase_38 AC 152 ms
43,032 KB
testcase_39 AC 152 ms
43,752 KB
testcase_40 AC 153 ms
43,524 KB
testcase_41 AC 180 ms
44,372 KB
testcase_42 AC 95 ms
39,032 KB
testcase_43 AC 104 ms
39,592 KB
testcase_44 AC 96 ms
39,372 KB
testcase_45 AC 100 ms
39,712 KB
testcase_46 AC 98 ms
39,180 KB
testcase_47 AC 106 ms
39,660 KB
testcase_48 AC 100 ms
39,204 KB
testcase_49 AC 73 ms
38,264 KB
testcase_50 AC 98 ms
38,908 KB
testcase_51 AC 98 ms
39,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int zero = 0;
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            int x = sc.nextInt();
            if (x == 0) {
                ans += zero * (long)(i - zero);
                zero = i;
            }
        }
        ans += zero * (long)(n + 1 - zero);
        System.out.println(ans);
    }
}

class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0