結果

問題 No.135 とりあえず1次元の問題
ユーザー GrenacheGrenache
提出日時 2015-09-23 20:53:50
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,913 bytes
コンパイル時間 3,526 ms
コンパイル使用メモリ 75,484 KB
実行使用メモリ 61,656 KB
最終ジャッジ日時 2023-09-01 21:39:50
合計ジャッジ時間 6,709 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 253 ms
61,496 KB
testcase_01 AC 45 ms
49,344 KB
testcase_02 WA -
testcase_03 AC 46 ms
49,800 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 48 ms
49,572 KB
testcase_13 AC 47 ms
49,528 KB
testcase_14 AC 53 ms
49,940 KB
testcase_15 AC 47 ms
49,472 KB
testcase_16 WA -
testcase_17 AC 53 ms
49,708 KB
testcase_18 AC 48 ms
49,340 KB
testcase_19 AC 52 ms
49,488 KB
testcase_20 AC 50 ms
49,372 KB
testcase_21 WA -
testcase_22 WA -
evil01.txt AC 254 ms
61,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;


public class Main_yukicoder135 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Printer pr = new Printer(System.out);

        int n = sc.nextInt();
        int[] x = new int[n];
        for (int i = 0; i < n; i++) {
        	x[i] = sc.nextInt();
        }
        Arrays.sort(x);

        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n - 1; i++) {
        	min = Math.min(min, Math.abs(x[i] - x[i + 1]));
        }

        if (min == Integer.MAX_VALUE) {
        	pr.println("0");
        } else {
        	pr.println(min);
        }

        pr.close();
        sc.close();
    }

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;
		
		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		
		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
					it = Arrays.asList(br.readLine().split(" ")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}
		
		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

		long nextLong() throws RuntimeException {
			return Long.parseLong(next());
		}

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0