結果

問題 No.370 道路の掃除
ユーザー YamaKasaYamaKasa
提出日時 2018-09-19 03:09:50
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 629 bytes
コンパイル時間 3,711 ms
コンパイル使用メモリ 71,796 KB
実行使用メモリ 58,388 KB
最終ジャッジ日時 2023-09-25 10:04:28
合計ジャッジ時間 8,537 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,824 KB
testcase_01 AC 118 ms
55,948 KB
testcase_02 AC 118 ms
55,620 KB
testcase_03 AC 119 ms
55,940 KB
testcase_04 AC 118 ms
55,964 KB
testcase_05 AC 119 ms
56,148 KB
testcase_06 AC 118 ms
55,800 KB
testcase_07 AC 119 ms
55,940 KB
testcase_08 AC 121 ms
55,944 KB
testcase_09 AC 120 ms
55,964 KB
testcase_10 AC 128 ms
55,812 KB
testcase_11 AC 129 ms
55,904 KB
testcase_12 AC 130 ms
53,832 KB
testcase_13 AC 130 ms
55,404 KB
testcase_14 AC 128 ms
55,504 KB
testcase_15 AC 130 ms
55,844 KB
testcase_16 AC 128 ms
55,676 KB
testcase_17 AC 129 ms
56,020 KB
testcase_18 AC 140 ms
56,100 KB
testcase_19 AC 129 ms
56,160 KB
testcase_20 AC 171 ms
58,388 KB
testcase_21 AC 191 ms
56,000 KB
testcase_22 AC 177 ms
56,148 KB
testcase_23 AC 170 ms
56,484 KB
testcase_24 AC 137 ms
55,752 KB
testcase_25 AC 165 ms
55,940 KB
testcase_26 AC 178 ms
56,012 KB
testcase_27 AC 143 ms
55,888 KB
testcase_28 AC 171 ms
56,108 KB
testcase_29 AC 177 ms
56,556 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		int []D = new int[M];
		for(int i = 0; i < M; i++) {
			D[i] = scan.nextInt();
		}
		scan.close();
		int min = Integer.MAX_VALUE;
		for(int i = 0; i <= M - N; i++) {
			int l = D[i];
			int r = D[i + N - 1];
			if(r < 0 && l < 0) {
				min = Math.min(min, -l);
			}else if(l <= 0 && r >= 0) {
				int t = Math.min(2 * r - l, -2 * l + r);
				min = Math.min(min, t);
			}else {
				min = Math.min(min, r);
			}
		}
		System.out.println(min);
	}
}
0