結果
問題 | No.1109 調の判定 |
ユーザー |
|
提出日時 | 2020-07-10 21:31:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 932 bytes |
コンパイル時間 | 1,807 ms |
コンパイル使用メモリ | 168,544 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 07:55:02 |
合計ジャッジ時間 | 2,699 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; using ll = long long ; using P = pair<int,int> ; using pll = pair<long long,long long>; constexpr int INF = 1e9; constexpr long long LINF = 1e17; constexpr int MOD = 1000000007; constexpr double PI = 3.14159265358979323846; vector<int> p = {0,2,4,5,7,9,11}; int main(){ int n; cin >> n; vector<int> cnt(20,0); rep(i,n){ int a; cin >> a; cnt[a] = 1; } int d = -1; rep(i,12){ bool res = true; rep(j,12){ if(cnt[j]==1){ bool ok = false; rep(k,p.size()){ if((i+p[k])%12==j) ok = true; } if(!ok) res = false; } } if(res&&d!=-1){d = INF;break;} if(res) d = i; } if(d==INF) cout << -1 << endl; else cout << d << endl; return 0; }