結果
問題 |
No.1109 調の判定
|
ユーザー |
|
提出日時 | 2020-07-10 21:42:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 662 bytes |
コンパイル時間 | 1,545 ms |
コンパイル使用メモリ | 168,408 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 08:34:50 |
合計ジャッジ時間 | 2,761 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int mod = 12; int main() { int n; cin >> n; int t[n]; for ( int i = 0; i < n; i++ ) { cin >> t[i]; } vector<int> judge = {0, 2, 4, 5, 7, 9, 11}; int ans = -1; for ( int k = 0; k < mod; k++ ) { bool check = true; for ( int i = 0; i < n; i++ ) { int d = ( t[i] >= k ) ? t[i]-k : (t[i]+12)-k; if ( find(judge.begin(), judge.end(), d) == judge.end() ) { check = false; break; } } if ( check ) { if ( ans == -1 ) { ans = k; } else { ans = -1; break; } } } cout << ans << endl; return 0; }