問題一覧 > 通常問題

No.1109 調の判定

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 324
作問者 : trineutron / テスター : face4
お気に入りにしたユーザー ProblemId : 3510 / 自分の提出
問題文最終更新日: 2022-04-26 02:01:17
Key Determination
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
yukicoder contest 256 (順位表) の他の問題:

Problem Statement

Orion is going to perform a choral piece. For this purpose, he has decided to determine the key of the piece. Analyzing the piece, he found that it uses a major scale and consists of the notes $T_1, T_2, \dots, T_N$. Determine the key of this piece and print the integer at least $0$ and less than $12$ that represents the key. If no such integer exists, or if more than one exists, print $-1$ instead. Here, when the key is $D$, the notes contained in the major scale are $\{ D, D+2, D+4, D+5, D+7, D+9, D+11 \} \pmod{12}$.

(Added 2020/07/10 22:07) When the key is $D$, the only notes that may be used are $D, D+2, D+4, D+5, D+7, D+9, D+11$, and it is possible that not all of them are used.

Input

$N$
$T_1\ T_2\ \dots\ T_N$

All inputs are integers.
$1 \le N \le 12$
$0 \le T_i < 12$
If $i < j$, then $T_i < T_j$

Output

If the key can be uniquely determined, print the integer at least $0$ and less than $12$ that represents the tonic of that key; otherwise, print $-1$. Print a newline at the end.

Sample

Sample 1
Input
5
0 2 6 7 11
Output
7

Sample 2
Input
3
2 6 10
Output
-1

There is no key that contains all of the notes $2, 6, 10$.

Sample 3
Input
5
0 2 4 7 9
Output
-1

There are 3 possible keys: $0, 5, 7$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。