結果

問題 No.1053 ゲーミング棒
ユーザー ks2mks2m
提出日時 2020-05-15 21:57:56
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 503 bytes
コンパイル時間 2,485 ms
コンパイル使用メモリ 73,972 KB
実行使用メモリ 62,008 KB
最終ジャッジ日時 2023-10-19 14:11:40
合計ジャッジ時間 12,858 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
57,080 KB
testcase_01 AC 145 ms
57,100 KB
testcase_02 AC 140 ms
57,556 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 140 ms
57,148 KB
testcase_06 WA -
testcase_07 AC 141 ms
57,464 KB
testcase_08 WA -
testcase_09 AC 138 ms
57,552 KB
testcase_10 WA -
testcase_11 AC 141 ms
57,708 KB
testcase_12 AC 140 ms
57,344 KB
testcase_13 WA -
testcase_14 AC 138 ms
57,512 KB
testcase_15 AC 137 ms
57,420 KB
testcase_16 AC 138 ms
57,096 KB
testcase_17 AC 140 ms
57,148 KB
testcase_18 AC 141 ms
57,164 KB
testcase_19 WA -
testcase_20 AC 141 ms
57,400 KB
testcase_21 AC 139 ms
57,144 KB
testcase_22 AC 138 ms
57,396 KB
testcase_23 AC 552 ms
61,972 KB
testcase_24 AC 556 ms
61,972 KB
testcase_25 AC 564 ms
61,948 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 140 ms
57,472 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 473 ms
61,832 KB
testcase_34 AC 490 ms
61,792 KB
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

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