結果
問題 |
No.1109 調の判定
|
ユーザー |
![]() |
提出日時 | 2020-08-04 12:43:45 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 137 ms / 2,000 ms |
コード長 | 1,162 bytes |
コンパイル時間 | 2,402 ms |
コンパイル使用メモリ | 77,888 KB |
実行使用メモリ | 41,728 KB |
最終ジャッジ日時 | 2024-09-14 13:26:41 |
合計ジャッジ時間 | 9,922 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws java.lang.Exception { // your code goes here // 入力 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(); } // 調リストの作成 List<List<Integer>> listChou = new ArrayList<>(); for(int i = 0; i < 12; i++){ List<Integer> chou = new ArrayList<>(); chou.add(i % 12); chou.add((i+2) % 12); chou.add((i+4) % 12); chou.add((i+5) % 12); chou.add((i+7) % 12); chou.add((i+9) % 12); chou.add((i+11) % 12); listChou.add(chou); } // 調の決定 int result = -1; for(int i = 0; i < 12; i++){ List<Integer> chou = listChou.get(i); boolean matching = true; for(int j = 0; j < N; j++){ if(!chou.contains(T[j])){ matching = false; break; } } if(matching){ if(result == -1){ result = i; }else{ result = -1; break; } } } // 出力 System.out.println(result); } }