結果

問題 No.370 道路の掃除
ユーザー sekiya9311sekiya9311
提出日時 2016-08-26 19:46:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 712 bytes
コンパイル時間 3,112 ms
コンパイル使用メモリ 78,064 KB
実行使用メモリ 56,676 KB
最終ジャッジ日時 2024-04-25 18:03:56
合計ジャッジ時間 9,115 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
53,904 KB
testcase_01 AC 116 ms
53,988 KB
testcase_02 AC 119 ms
54,124 KB
testcase_03 AC 106 ms
53,068 KB
testcase_04 AC 106 ms
53,032 KB
testcase_05 AC 106 ms
52,856 KB
testcase_06 AC 107 ms
52,872 KB
testcase_07 AC 117 ms
54,124 KB
testcase_08 AC 120 ms
53,904 KB
testcase_09 AC 118 ms
54,040 KB
testcase_10 AC 128 ms
54,304 KB
testcase_11 AC 127 ms
53,944 KB
testcase_12 AC 125 ms
54,024 KB
testcase_13 AC 124 ms
54,208 KB
testcase_14 AC 125 ms
54,204 KB
testcase_15 AC 128 ms
53,992 KB
testcase_16 AC 133 ms
54,228 KB
testcase_17 AC 132 ms
54,136 KB
testcase_18 AC 128 ms
54,592 KB
testcase_19 AC 128 ms
54,380 KB
testcase_20 AC 165 ms
54,516 KB
testcase_21 AC 164 ms
54,288 KB
testcase_22 AC 164 ms
54,748 KB
testcase_23 AC 163 ms
54,384 KB
testcase_24 AC 129 ms
54,280 KB
testcase_25 AC 163 ms
54,448 KB
testcase_26 AC 164 ms
54,784 KB
testcase_27 AC 143 ms
54,208 KB
testcase_28 AC 160 ms
54,164 KB
testcase_29 AC 163 ms
54,300 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yuki370 {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N, M;
		N = sc.nextInt();
		M = sc.nextInt();
		int[] D = new int[M];
		for (int i = 0; i < M; i++) {
			D[i] = sc.nextInt();
		}
		int ans = (int) 1e9;
		for (int i = 0; i + N - 1 < D.length; i++) {
			if (0 <= D[i]) {
				ans = Math.min(ans, Math.abs(D[i + N - 1]));
			} else if (D[i] < 0 && 0 < D[i + N - 1]) {
				int buf = Math.abs(D[i]) * 2 + Math.abs(D[i + N - 1]);
				buf = Math.min(buf, Math.abs(D[i]) + Math.abs(D[i + N - 1]) * 2);
				ans = Math.min(ans, buf);
			} else {
				ans = Math.min(ans, Math.abs(D[i]));
			}
		}
		System.out.println(ans);
	}
}
0