結果

問題 No.1109 調の判定
ユーザー tentententen
提出日時 2020-08-18 08:17:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 1,105 bytes
コンパイル時間 2,323 ms
コンパイル使用メモリ 79,012 KB
実行使用メモリ 41,800 KB
最終ジャッジ日時 2024-04-20 02:52:08
合計ジャッジ時間 8,526 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
41,548 KB
testcase_01 AC 119 ms
41,240 KB
testcase_02 AC 121 ms
41,388 KB
testcase_03 AC 123 ms
40,848 KB
testcase_04 AC 124 ms
41,304 KB
testcase_05 AC 121 ms
41,576 KB
testcase_06 AC 106 ms
41,356 KB
testcase_07 AC 117 ms
41,244 KB
testcase_08 AC 122 ms
41,248 KB
testcase_09 AC 117 ms
41,032 KB
testcase_10 AC 117 ms
41,224 KB
testcase_11 AC 103 ms
41,324 KB
testcase_12 AC 121 ms
41,508 KB
testcase_13 AC 118 ms
39,836 KB
testcase_14 AC 108 ms
41,224 KB
testcase_15 AC 107 ms
41,236 KB
testcase_16 AC 120 ms
41,436 KB
testcase_17 AC 124 ms
41,800 KB
testcase_18 AC 121 ms
41,384 KB
testcase_19 AC 119 ms
41,444 KB
testcase_20 AC 108 ms
41,204 KB
testcase_21 AC 110 ms
41,388 KB
testcase_22 AC 116 ms
41,372 KB
testcase_23 AC 117 ms
41,252 KB
testcase_24 AC 120 ms
41,232 KB
testcase_25 AC 120 ms
41,028 KB
testcase_26 AC 107 ms
41,612 KB
testcase_27 AC 119 ms
41,548 KB
testcase_28 AC 119 ms
41,556 KB
testcase_29 AC 107 ms
41,136 KB
testcase_30 AC 106 ms
41,244 KB
testcase_31 AC 118 ms
41,244 KB
testcase_32 AC 122 ms
41,384 KB
testcase_33 AC 107 ms
41,328 KB
testcase_34 AC 123 ms
41,348 KB
testcase_35 AC 117 ms
41,304 KB
testcase_36 AC 113 ms
41,196 KB
testcase_37 AC 107 ms
41,084 KB
testcase_38 AC 100 ms
41,552 KB
testcase_39 AC 130 ms
41,228 KB
testcase_40 AC 122 ms
41,488 KB
testcase_41 AC 106 ms
41,228 KB
testcase_42 AC 125 ms
41,544 KB
testcase_43 AC 107 ms
41,376 KB
testcase_44 AC 120 ms
41,248 KB
testcase_45 AC 123 ms
41,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<Integer> correct = new HashSet<>();
        correct.add(0);
        correct.add(2);
        correct.add(4);
        correct.add(5);
        correct.add(7);
        correct.add(9);
        correct.add(11);
        boolean[] durs = new boolean[12];
        Arrays.fill(durs, true);
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            for (int j = 0; j < 12; j++) {
                if (!durs[j]) {
                    continue;
                }
                if (!correct.contains((x - j + 12) % 12)) {
                    durs[j] = false;
                }
            }
        }
        int ans = -1;
        for (int i = 0; i < 12; i++) {
            if (durs[i]) {
                if (ans == -1) {
                    ans = i;
                } else {
                    ans = -1;
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}
0