結果
問題 |
No.1109 調の判定
|
ユーザー |
![]() |
提出日時 | 2020-07-10 21:34:38 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 148 ms / 2,000 ms |
コード長 | 881 bytes |
コンパイル時間 | 2,471 ms |
コンパイル使用メモリ | 77,120 KB |
実行使用メモリ | 41,368 KB |
最終ジャッジ日時 | 2024-10-11 08:04:54 |
合計ジャッジ時間 | 10,242 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
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); } }