結果

問題 No.1109 調の判定
ユーザー face4face4
提出日時 2019-11-14 23:06:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 1,437 bytes
コンパイル時間 2,049 ms
コンパイル使用メモリ 77,740 KB
実行使用メモリ 53,512 KB
最終ジャッジ日時 2023-10-22 03:20:51
合計ジャッジ時間 5,980 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
52,432 KB
testcase_01 AC 56 ms
53,492 KB
testcase_02 AC 55 ms
53,428 KB
testcase_03 AC 55 ms
53,496 KB
testcase_04 AC 55 ms
53,500 KB
testcase_05 AC 56 ms
53,492 KB
testcase_06 AC 55 ms
53,488 KB
testcase_07 AC 56 ms
53,488 KB
testcase_08 AC 55 ms
53,484 KB
testcase_09 AC 56 ms
53,484 KB
testcase_10 AC 55 ms
53,428 KB
testcase_11 AC 55 ms
53,488 KB
testcase_12 AC 56 ms
53,484 KB
testcase_13 AC 54 ms
53,484 KB
testcase_14 AC 56 ms
53,480 KB
testcase_15 AC 55 ms
53,484 KB
testcase_16 AC 54 ms
53,492 KB
testcase_17 AC 55 ms
53,488 KB
testcase_18 AC 54 ms
53,428 KB
testcase_19 AC 54 ms
53,424 KB
testcase_20 AC 56 ms
53,484 KB
testcase_21 AC 56 ms
52,368 KB
testcase_22 AC 55 ms
53,496 KB
testcase_23 AC 57 ms
53,500 KB
testcase_24 AC 55 ms
53,492 KB
testcase_25 AC 56 ms
53,496 KB
testcase_26 AC 56 ms
52,384 KB
testcase_27 AC 56 ms
53,488 KB
testcase_28 AC 54 ms
53,480 KB
testcase_29 AC 54 ms
53,484 KB
testcase_30 AC 56 ms
53,484 KB
testcase_31 AC 56 ms
53,484 KB
testcase_32 AC 56 ms
53,496 KB
testcase_33 AC 55 ms
53,484 KB
testcase_34 AC 55 ms
53,424 KB
testcase_35 AC 55 ms
53,500 KB
testcase_36 AC 56 ms
53,492 KB
testcase_37 AC 54 ms
53,480 KB
testcase_38 AC 55 ms
53,480 KB
testcase_39 AC 55 ms
53,488 KB
testcase_40 AC 55 ms
53,484 KB
testcase_41 AC 54 ms
53,488 KB
testcase_42 AC 55 ms
53,484 KB
testcase_43 AC 55 ms
53,484 KB
testcase_44 AC 56 ms
53,496 KB
testcase_45 AC 56 ms
53,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;

public class Main{
    public static void main(String args[]) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String line = br.readLine();
        if(line.charAt(line.length()-1) == ' ') System.exit(1);
        int n = Integer.parseInt(line);
        if(!(1 <= n && n <= 12)) System.exit(1);

        line = br.readLine();
        if(line.charAt(line.length()-1) == ' ') System.exit(1);
        String[] tmp = line.split(" ");
        if(tmp.length != n) System.exit(1);

        int[] arr = new int[n];
        for(int i = 0; i < n; i++)  arr[i] = Integer.parseInt(tmp[i]);

        for(int i = 1; i < n; i++){
            if(!(arr[i-1] < arr[i]))   System.exit(1);
        }

        boolean[] x = new boolean[12];
        for(int i = 0; i < n; i++){
            if(!(0 <= arr[i] && arr[i] < 12))   System.exit(1);
            x[arr[i]] = true;
        }

        int[] add = {0, 2, 4, 5, 7, 9, 11};
        int ans = -1;
        for(int i = 0; i < 12; i++){
            int count = 0;
            for(int j : add){
                if(x[(i+j)%12]) count++;
            }
            if(count != n)  continue;
            if(ans != -1){
                ans = -1;
                break;
            }
            ans = i;
        }
        System.out.println(ans);
    }
}
0