結果

問題 No.1109 調の判定
ユーザー face4
提出日時 2019-11-14 22:51:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 706 bytes
コンパイル時間 512 ms
コンパイル使用メモリ 65,780 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-22 04:35:00
合計ジャッジ時間 2,084 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cassert>
using namespace std;

int main(){
    int n;
    cin >> n;
    
    assert(1 <= n && n <= 12);

    bool t[12] = {};
    int bef = -1;
    for(int i = 0; i < n; i++){
        int x;  cin >> x;
        assert(0 <= x && x < 12);
        assert(bef < x);
        assert(!t[x]);
        t[x] = true;
        bef = x;
    }

    int ans = -1;
    for(int i = 0; i < 12; i++){
        int cnt = 0;
        for(int j : {0, 2, 4, 5, 7, 9, 11}){
            cnt += t[(j+i)%12];
        }
        if(cnt != n)    continue;
        if(ans != -1){
            cout << -1 << endl;
            return 0;
        }
        ans = i;
    }
    
    cout << ans << endl;

    return 0;
}
0