結果

問題 No.1109 調の判定
ユーザー misora192
提出日時 2020-07-10 22:29:18
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 861 bytes
コンパイル時間 1,821 ms
コンパイル使用メモリ 173,276 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-11 09:46:07
合計ジャッジ時間 3,288 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	set<int> st;
	rep(i, n){
		int t;
		cin >> t;

		st.insert(t);
	}

	int cnt = 0;
	int x = -1;
	rep(i, 12){
		int u = 0;
		if(st.count((i) % 12) == 1) u++;
		if(st.count((i+2) % 12) == 1) u++;
		if(st.count((i+4) % 12) == 1) u++;
		if(st.count((i+5) % 12) == 1) u++;
		if(st.count((i+7) % 12) == 1) u++;
		if(st.count((i+9) % 12) == 1) u++;
		if(st.count((i+11) % 12) == 1) u++;
		if(u == n) {
			cnt++;
			x = i;
		}
	}

	if(cnt == 1){
		cout << x << endl;
	}else{
		cout << -1 << endl;
	}
}
0