結果
| 問題 |
No.1053 ゲーミング棒
|
| コンテスト | |
| ユーザー |
ks2m
|
| 提出日時 | 2020-05-15 22:08:59 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 758 bytes |
| コンパイル時間 | 2,586 ms |
| コンパイル使用メモリ | 77,708 KB |
| 実行使用メモリ | 53,468 KB |
| 最終ジャッジ日時 | 2024-09-19 10:44:01 |
| 合計ジャッジ時間 | 12,130 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 WA * 3 |
ソースコード
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
sc.close();
Set<Integer> set = new HashSet<>();
set.add(a[0]);
for (int i = 1; i < n - 1; i++) {
if (a[i] != a[i - 1] && set.contains(a[i])) {
for (int j = i + 1; j < n; j++) {
if (a[i] != a[j]) {
System.out.println(-1);
return;
}
}
System.out.println(1);
return;
}
set.add(a[i]);
}
if (a[0] == a[n - 1] && set.size() > 1) {
System.out.println(1);
} else {
System.out.println(0);
}
}
}
ks2m