結果

問題 No.1053 ゲーミング棒
ユーザー ks2m
提出日時 2020-05-15 21:57:56
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 503 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 74,444 KB
実行使用メモリ 59,428 KB
最終ジャッジ日時 2024-09-19 10:20:24
合計ジャッジ時間 11,892 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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();

		int[] c = new int[n + 1];
		for (int i = 0; i < n - 1; i++) {
			if (c[a[i]]++ > 0) {
				System.out.println(-1);
				return;
			}
		}
		if (a[0] == a[n - 1]) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}
	}
}
0