結果
| 問題 |
No.1109 調の判定
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-10 21:58:50 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 922 bytes |
| コンパイル時間 | 13,543 ms |
| コンパイル使用メモリ | 375,528 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-11 09:08:48 |
| 合計ジャッジ時間 | 15,128 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
ソースコード
use std::io::*;
fn main() {
let mut s: String = String::new();
std::io::stdin().read_to_string(&mut s).ok();
let mut itr = s.trim().split_whitespace();
let n: usize = itr.next().unwrap().parse().unwrap();
let a: Vec<usize> = (0..n)
.map(|_| itr.next().unwrap().parse().unwrap())
.collect();
let b = [0, 2, 4, 5, 7, 9, 11].to_vec();
let mut ans: i32 = -1;
for d in 0..12 {
let mut ok = true;
for i in 0..n {
let mut ng = true;
for j in 0..7 {
if (d + b[j]) % 12 == a[i] {
ng = false;
}
}
if ng {
ok = false;
}
}
if ok {
if ans == -1 {
ans = d as i32;
} else {
println!("-1");
return;
}
}
}
println!("{}", ans);
}