結果

問題 No.406 鴨等間隔の法則
ユーザー RinRin
提出日時 2016-09-09 10:33:32
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 843 bytes
コンパイル時間 3,497 ms
コンパイル使用メモリ 77,884 KB
実行使用メモリ 48,612 KB
最終ジャッジ日時 2024-04-24 20:54:47
合計ジャッジ時間 18,883 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 459 ms
48,180 KB
testcase_01 AC 123 ms
41,276 KB
testcase_02 AC 124 ms
40,924 KB
testcase_03 AC 112 ms
40,444 KB
testcase_04 AC 591 ms
48,612 KB
testcase_05 AC 441 ms
48,200 KB
testcase_06 AC 410 ms
47,960 KB
testcase_07 AC 429 ms
47,944 KB
testcase_08 AC 656 ms
48,400 KB
testcase_09 AC 667 ms
48,384 KB
testcase_10 AC 484 ms
48,284 KB
testcase_11 AC 603 ms
48,152 KB
testcase_12 AC 504 ms
48,340 KB
testcase_13 AC 533 ms
48,124 KB
testcase_14 WA -
testcase_15 AC 231 ms
45,716 KB
testcase_16 AC 250 ms
45,708 KB
testcase_17 AC 215 ms
44,596 KB
testcase_18 AC 246 ms
45,832 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 286 ms
46,668 KB
testcase_22 WA -
testcase_23 AC 505 ms
48,120 KB
testcase_24 WA -
testcase_25 AC 598 ms
48,576 KB
testcase_26 WA -
testcase_27 AC 567 ms
48,392 KB
testcase_28 AC 570 ms
48,140 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 626 ms
48,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class b {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int foo[] = new int[N];
		for(int i = 0; i < N; i++)
			foo[i] = sc.nextInt();
		int min = 114514810;
		int min2th = 364364893;
		for(int i = 1; i < N; i++){
			if(foo[i] < min){
				min2th = min;
				min = foo[i];
			}else if(foo[i] < min2th){
				min2th = foo[i];
			}
			if(foo[i] < foo[i - 1]){
				int tmp = foo[i];
				foo[i] = foo[i - 1];
				foo[i - 1] = tmp;
			}else if(foo[i] == foo[i - 1]){
				System.out.println("NO");
				return;
			}
		}
		int bar = min2th - min;
		if(bar == 0){
			System.out.println("NO");
			return;
		}
		for(int i = 0; i < N - 1; i++){
			if(foo[i] + bar != foo[i + 1]){
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}
0