結果

問題 No.1109 調の判定
ユーザー ks2mks2m
提出日時 2020-07-10 21:34:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 881 bytes
コンパイル時間 1,950 ms
コンパイル使用メモリ 77,276 KB
実行使用メモリ 41,836 KB
最終ジャッジ日時 2024-04-19 15:58:31
合計ジャッジ時間 8,076 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
41,500 KB
testcase_01 AC 106 ms
41,412 KB
testcase_02 AC 106 ms
41,548 KB
testcase_03 AC 113 ms
41,616 KB
testcase_04 AC 114 ms
41,448 KB
testcase_05 AC 116 ms
41,168 KB
testcase_06 AC 116 ms
41,616 KB
testcase_07 AC 105 ms
41,676 KB
testcase_08 AC 102 ms
41,484 KB
testcase_09 AC 104 ms
41,528 KB
testcase_10 AC 103 ms
41,348 KB
testcase_11 AC 105 ms
41,740 KB
testcase_12 AC 118 ms
41,624 KB
testcase_13 AC 104 ms
41,612 KB
testcase_14 AC 108 ms
41,728 KB
testcase_15 AC 115 ms
41,192 KB
testcase_16 AC 103 ms
41,408 KB
testcase_17 AC 103 ms
41,544 KB
testcase_18 AC 114 ms
41,652 KB
testcase_19 AC 115 ms
41,188 KB
testcase_20 AC 105 ms
41,444 KB
testcase_21 AC 110 ms
41,364 KB
testcase_22 AC 107 ms
41,608 KB
testcase_23 AC 121 ms
41,480 KB
testcase_24 AC 111 ms
41,536 KB
testcase_25 AC 118 ms
41,836 KB
testcase_26 AC 118 ms
41,628 KB
testcase_27 AC 112 ms
41,400 KB
testcase_28 AC 111 ms
41,576 KB
testcase_29 AC 103 ms
41,492 KB
testcase_30 AC 112 ms
41,452 KB
testcase_31 AC 103 ms
41,468 KB
testcase_32 AC 103 ms
41,572 KB
testcase_33 AC 105 ms
41,556 KB
testcase_34 AC 112 ms
41,456 KB
testcase_35 AC 117 ms
41,576 KB
testcase_36 AC 98 ms
41,612 KB
testcase_37 AC 115 ms
41,532 KB
testcase_38 AC 102 ms
41,164 KB
testcase_39 AC 99 ms
41,616 KB
testcase_40 AC 101 ms
41,348 KB
testcase_41 AC 103 ms
41,312 KB
testcase_42 AC 114 ms
41,600 KB
testcase_43 AC 111 ms
41,492 KB
testcase_44 AC 104 ms
41,320 KB
testcase_45 AC 105 ms
41,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] t = new int[n];
		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}
		sc.close();

		int[] d = {0, 2, 4, 5, 7, 9, 11};
		boolean[] match = new boolean[12];
		Arrays.fill(match, true);
		for (int i = 0; i < 12; i++) {
			for (int j = 0; j < n; j++) {
				boolean flg = false;
				for (int j2 = 0; j2 < d.length; j2++) {
					if (t[j] == (i + d[j2]) % 12) {
						flg = true;
						break;
					}
				}
				if (!flg) {
					match[i] = false;
					break;
				}
			}
		}
		int ans = -1;
		for (int i = 0; i < 12; i++) {
			if (match[i]) {
				if (ans == -1) {
					ans = i;
				} else {
					System.out.println(-1);
					return;
				}
			}
		}
		System.out.println(ans);
	}
}
0