結果

問題 No.1053 ゲーミング棒
ユーザー ks2mks2m
提出日時 2020-05-15 22:02:18
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 548 bytes
コンパイル時間 3,472 ms
コンパイル使用メモリ 74,244 KB
実行使用メモリ 59,396 KB
最終ジャッジ日時 2024-09-19 10:31:26
合計ジャッジ時間 13,348 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
41,288 KB
testcase_01 AC 131 ms
41,356 KB
testcase_02 AC 127 ms
41,088 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 121 ms
41,396 KB
testcase_06 AC 132 ms
41,020 KB
testcase_07 AC 117 ms
41,216 KB
testcase_08 AC 120 ms
41,344 KB
testcase_09 AC 119 ms
41,312 KB
testcase_10 AC 122 ms
41,288 KB
testcase_11 AC 111 ms
41,500 KB
testcase_12 AC 121 ms
41,236 KB
testcase_13 AC 118 ms
41,256 KB
testcase_14 AC 122 ms
41,136 KB
testcase_15 AC 122 ms
41,076 KB
testcase_16 AC 119 ms
41,388 KB
testcase_17 AC 125 ms
41,356 KB
testcase_18 AC 123 ms
41,408 KB
testcase_19 AC 119 ms
41,260 KB
testcase_20 AC 128 ms
41,312 KB
testcase_21 AC 123 ms
41,200 KB
testcase_22 AC 124 ms
41,080 KB
testcase_23 AC 507 ms
48,080 KB
testcase_24 AC 574 ms
48,652 KB
testcase_25 AC 564 ms
49,220 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 123 ms
41,312 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 407 ms
48,176 KB
testcase_34 AC 452 ms
48,624 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];
		c[a[0]]++;
		for (int i = 1; i < n - 1; i++) {
			if (a[i] != a[i - 1] && c[a[i]] > 0) {
				System.out.println(-1);
				return;
			}
			c[a[i]]++;
		}
		if (a[0] == a[n - 1]) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}
	}
}
0