結果

問題 No.1109 調の判定
ユーザー
提出日時 2020-08-02 03:36:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 936 bytes
コンパイル時間 1,036 ms
コンパイル使用メモリ 98,968 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-16 03:55:43
合計ジャッジ時間 2,224 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int h[10] = { 0,2,4,5,7,9,11 };
int main() {
	int n;
	int t[20];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	int ans;
	bool b = true, bo = false;
	for (int i = 0; i < 12; i++) {
		vector<int> vec;
		for (int j = 0; j < 7; j++) {
			vec.emplace_back((i + h[j]) % 12);
		}
		sort(vec.begin(), vec.end());
		b = true;
		for (int j = 0; j < n; j++) {
			if (!binary_search(vec.begin(), vec.end(), t[j])) {
				b = false;
			}
		}
		if (b) {
			if (bo) {
				cout << "-1" << endl;
				return 0;
			}
			else {
				bo = true;
				ans = i;
			}
		}
	}
	if (bo) {
		cout << ans << endl;
	}
	else {
		cout << "-1" << endl;
	}
	return 0;
}

0