結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 517 ms
48,128 KB
testcase_01 AC 131 ms
41,576 KB
testcase_02 AC 134 ms
41,220 KB
testcase_03 AC 135 ms
41,268 KB
testcase_04 AC 664 ms
48,492 KB
testcase_05 AC 456 ms
48,344 KB
testcase_06 AC 498 ms
47,948 KB
testcase_07 AC 473 ms
48,332 KB
testcase_08 AC 623 ms
48,220 KB
testcase_09 AC 681 ms
48,476 KB
testcase_10 AC 499 ms
47,908 KB
testcase_11 AC 597 ms
48,380 KB
testcase_12 AC 554 ms
48,372 KB
testcase_13 AC 547 ms
48,336 KB
testcase_14 WA -
testcase_15 AC 227 ms
45,868 KB
testcase_16 AC 265 ms
45,660 KB
testcase_17 AC 219 ms
44,516 KB
testcase_18 AC 269 ms
46,180 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 315 ms
47,620 KB
testcase_22 WA -
testcase_23 AC 533 ms
48,428 KB
testcase_24 WA -
testcase_25 AC 700 ms
48,776 KB
testcase_26 WA -
testcase_27 AC 593 ms
48,208 KB
testcase_28 AC 593 ms
48,052 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 620 ms
48,424 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 = 19194545;
		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