結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 487 ms
48,080 KB
testcase_01 AC 123 ms
41,364 KB
testcase_02 AC 123 ms
41,256 KB
testcase_03 AC 123 ms
40,944 KB
testcase_04 AC 617 ms
48,556 KB
testcase_05 AC 371 ms
46,956 KB
testcase_06 AC 439 ms
48,208 KB
testcase_07 AC 379 ms
46,540 KB
testcase_08 AC 593 ms
48,612 KB
testcase_09 AC 505 ms
48,192 KB
testcase_10 AC 447 ms
47,880 KB
testcase_11 AC 562 ms
48,236 KB
testcase_12 AC 488 ms
48,476 KB
testcase_13 AC 532 ms
48,404 KB
testcase_14 WA -
testcase_15 AC 248 ms
45,968 KB
testcase_16 AC 253 ms
46,280 KB
testcase_17 AC 215 ms
44,796 KB
testcase_18 AC 262 ms
45,948 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 282 ms
47,588 KB
testcase_22 WA -
testcase_23 AC 529 ms
48,188 KB
testcase_24 WA -
testcase_25 AC 596 ms
48,552 KB
testcase_26 WA -
testcase_27 AC 532 ms
48,388 KB
testcase_28 AC 500 ms
48,092 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 639 ms
48,456 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;
		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