結果

問題 No.1109 調の判定
ユーザー tobusakana
提出日時 2020-08-23 12:34:46
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 556 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-10-15 18:07:51
合計ジャッジ時間 2,783 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!

N = int(input())
T = list(map(int,input().split()))

R = (0,2,4,5,7,9,11)

def check(t,d):
    candi = set()
    for r in R:
        candi.add((d + r) % 12)
        
    for t in T:
        if t not in candi:
            return False
    return True
    
ans = None
for D in range(12):
    # その調ですべてのTが当てはまるかチェック
    if check(T,D):
        if ans is None:
            ans = D
        else:
            print(-1)
            exit(0)
if ans is None:
    print(-1)
else:
    print(ans)
0