結果

問題 No.135 とりあえず1次元の問題
ユーザー tsunatama5tsunatama5
提出日時 2015-09-20 23:58:34
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 855 bytes
コンパイル時間 4,443 ms
コンパイル使用メモリ 74,208 KB
実行使用メモリ 69,864 KB
最終ジャッジ日時 2023-09-01 21:38:13
合計ジャッジ時間 8,903 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 391 ms
65,948 KB
testcase_01 AC 121 ms
55,808 KB
testcase_02 AC 120 ms
56,124 KB
testcase_03 AC 118 ms
55,852 KB
testcase_04 WA -
testcase_05 AC 123 ms
55,788 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 161 ms
56,140 KB
testcase_20 WA -
testcase_21 AC 416 ms
69,864 KB
testcase_22 AC 391 ms
66,488 KB
evil01.txt AC 384 ms
66,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package P135;

import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class P135 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		int nint = Integer.parseInt(n);
		String l = sc.nextLine();
		String[] lstrs = l.split(" ");

		int lint[] = new int[nint];
		int i = 0;
		int cmax = nint - 1;
		
		for (i=0;i<=cmax;i++) {
			lint[i] = Integer.parseInt(lstrs[i]);
		}
		
		int j;
		int temp = 0;
		int ans = 1000000;
		int max = 0;
		int min = 1000000;
		
//		Arrays.sort(lint);
		
		for (i=1;i<=cmax;i++) {
			temp = Math.abs(lint[i-1] - lint[i]);
			if (ans > temp && lint[i] != lint[i-1]) {
				ans = temp;
			}
			if (max < temp){
				max = temp;
			}
			if (min > temp) {
				min = temp;
			}
		}
		if (max == min) {
			ans = 0;
		}

		System.out.println(ans);
	}
}

0