結果

問題 No.1109 調の判定
ユーザー RISE70226821RISE70226821
提出日時 2020-08-04 12:43:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 1,162 bytes
コンパイル時間 2,358 ms
コンパイル使用メモリ 74,992 KB
実行使用メモリ 56,264 KB
最終ジャッジ日時 2023-10-12 14:33:28
合計ジャッジ時間 11,402 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,988 KB
testcase_01 AC 127 ms
56,032 KB
testcase_02 AC 128 ms
56,024 KB
testcase_03 AC 127 ms
55,892 KB
testcase_04 AC 131 ms
55,716 KB
testcase_05 AC 128 ms
55,772 KB
testcase_06 AC 129 ms
55,916 KB
testcase_07 AC 131 ms
55,660 KB
testcase_08 AC 128 ms
55,528 KB
testcase_09 AC 126 ms
55,696 KB
testcase_10 AC 126 ms
54,060 KB
testcase_11 AC 130 ms
55,904 KB
testcase_12 AC 130 ms
55,568 KB
testcase_13 AC 130 ms
55,988 KB
testcase_14 AC 128 ms
55,736 KB
testcase_15 AC 133 ms
56,092 KB
testcase_16 AC 132 ms
56,264 KB
testcase_17 AC 128 ms
55,680 KB
testcase_18 AC 128 ms
56,020 KB
testcase_19 AC 128 ms
55,848 KB
testcase_20 AC 128 ms
55,868 KB
testcase_21 AC 128 ms
55,568 KB
testcase_22 AC 127 ms
56,020 KB
testcase_23 AC 128 ms
56,088 KB
testcase_24 AC 128 ms
55,896 KB
testcase_25 AC 128 ms
55,768 KB
testcase_26 AC 129 ms
55,772 KB
testcase_27 AC 128 ms
55,760 KB
testcase_28 AC 128 ms
56,120 KB
testcase_29 AC 128 ms
55,732 KB
testcase_30 AC 127 ms
56,116 KB
testcase_31 AC 127 ms
55,972 KB
testcase_32 AC 130 ms
55,860 KB
testcase_33 AC 130 ms
55,532 KB
testcase_34 AC 128 ms
55,948 KB
testcase_35 AC 127 ms
55,568 KB
testcase_36 AC 127 ms
55,840 KB
testcase_37 AC 129 ms
53,692 KB
testcase_38 AC 129 ms
55,956 KB
testcase_39 AC 129 ms
55,772 KB
testcase_40 AC 129 ms
56,100 KB
testcase_41 AC 127 ms
55,884 KB
testcase_42 AC 126 ms
55,940 KB
testcase_43 AC 127 ms
55,808 KB
testcase_44 AC 127 ms
55,784 KB
testcase_45 AC 127 ms
55,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
	}

}
0