結果

問題 No.1109 調の判定
ユーザー kpinkcat
提出日時 2023-08-26 23:55:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 964 bytes
コンパイル時間 1,044 ms
コンパイル使用メモリ 103,976 KB
最終ジャッジ日時 2025-02-16 14:54:38
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<map>
#include<vector>
#include <algorithm>
#include<math.h>
#include <iomanip>
#include<set>
#include <numeric>
using namespace std;


int main()
{
    int n, ans=0, onlyone = 0;
    bool no1, no2;
    cin >> n;
    vector<int> v(n), d = {0, 2, 4, 5, 7, 9, 11};
    for (int i = 0; i < n; i++) cin >> v[i];
    for (int k = 0; k < 12; k++){
        no2 = true;
        for (int i = 0; i < n; i++){
            no1 = true;
            for (int j = 0; j < 7; j++){
                if ((v[i] - k + 12)%12 == d[j]){
                    no1 = false;
                    break;
                }
            }
            if (no1) break;
            if (i == n-1) no2 = false;
        }
        if (!no2){
            onlyone++;
            ans = k;
            if (onlyone >= 2){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    if (onlyone) cout << ans << endl;
    else cout << -1 << endl;
}
0