結果

問題 No.1109 調の判定
ユーザー mot
提出日時 2020-07-10 21:52:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 951 bytes
コンパイル時間 799 ms
コンパイル使用メモリ 94,556 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-11 08:56:22
合計ジャッジ時間 2,107 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int T[N];
  for(int i=0;i<N;++i){
    cin>>T[i];
  }
  vector<int> ans;
  bool ok;
  for(int i=0;i<12;++i){
    ok = true;
    map<int, int> amap;
    amap[i%12]++;
    amap[(i+2)%12]++;
    amap[(i+4)%12]++;
    amap[(i+5)%12]++;
    amap[(i+7)%12]++;
    amap[(i+9)%12]++;
    amap[(i+11)%12]++;
    for(int j=0;j<N;++j){
      if(amap[T[j]%12]==0) ok = false;
    }
    if(ok) ans.push_back(i);
  }
  if(ans.size()==1) cout<<ans[0]<<endl;
  else cout<<-1<<endl;
}

0