結果

問題 No.370 道路の掃除
ユーザー t8m8⛄️t8m8⛄️
提出日時 2016-08-17 15:22:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 238 ms / 2,000 ms
コード長 1,061 bytes
コンパイル時間 3,933 ms
コンパイル使用メモリ 81,736 KB
実行使用メモリ 43,232 KB
最終ジャッジ日時 2024-04-25 08:22:11
合計ジャッジ時間 11,254 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
41,724 KB
testcase_01 AC 135 ms
40,536 KB
testcase_02 AC 152 ms
41,704 KB
testcase_03 AC 134 ms
40,716 KB
testcase_04 AC 152 ms
41,616 KB
testcase_05 AC 156 ms
41,584 KB
testcase_06 AC 152 ms
41,456 KB
testcase_07 AC 149 ms
41,476 KB
testcase_08 AC 156 ms
41,412 KB
testcase_09 AC 132 ms
40,520 KB
testcase_10 AC 163 ms
41,788 KB
testcase_11 AC 164 ms
41,792 KB
testcase_12 AC 162 ms
42,028 KB
testcase_13 AC 159 ms
41,724 KB
testcase_14 AC 159 ms
41,968 KB
testcase_15 AC 166 ms
41,672 KB
testcase_16 AC 164 ms
41,840 KB
testcase_17 AC 162 ms
41,720 KB
testcase_18 AC 163 ms
41,964 KB
testcase_19 AC 167 ms
41,708 KB
testcase_20 AC 206 ms
42,568 KB
testcase_21 AC 233 ms
42,736 KB
testcase_22 AC 231 ms
42,360 KB
testcase_23 AC 213 ms
42,596 KB
testcase_24 AC 166 ms
41,836 KB
testcase_25 AC 189 ms
42,512 KB
testcase_26 AC 238 ms
42,748 KB
testcase_27 AC 174 ms
42,024 KB
testcase_28 AC 186 ms
42,568 KB
testcase_29 AC 207 ms
42,660 KB
testcase_30 AC 219 ms
42,896 KB
testcase_31 AC 210 ms
42,512 KB
testcase_32 AC 218 ms
42,740 KB
testcase_33 AC 219 ms
43,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class No0370 {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int n = in.nextInt();
		int m = in.nextInt();
		int[] d = new int[m];
		for (int i=0; i<m; i++) {
			d[i] = in.nextInt();
		}
		Arrays.sort(d);
		int ans = Integer.MAX_VALUE/2;
		int l = 0, r = n-1;
		while (r < m) {
			if (d[r] <= 0) {
				ans = Math.min(ans, -d[l]);
			} else if (0 <= d[l]) {
				ans = Math.min(ans, d[r]);
			} else {
				ans = Math.min(ans, Math.min(-2*d[l] + d[r], -d[l] + 2*d[r]));
			}
			l++; r++;
		}
		out.println(ans);
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}
0