結果
| 問題 |
No.370 道路の掃除
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-09-28 20:19:57 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 528 bytes |
| コンパイル時間 | 6,012 ms |
| コンパイル使用メモリ | 74,468 KB |
| 実行使用メモリ | 54,788 KB |
| 最終ジャッジ日時 | 2024-11-21 08:31:09 |
| 合計ジャッジ時間 | 12,194 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 WA * 4 |
ソースコード
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int N = scn.nextInt();
int M = scn.nextInt();
int dp[] = new int[M];
int ans = Integer.MAX_VALUE;
for(int i=0; i<M; i++){
dp[i] = scn.nextInt();
}
Arrays.sort(dp);
for(int i=0; i<M-N; i++){
ans = Math.min(ans , Math.abs(dp[i]-dp[i+N-1]) +
Math.min(Math.abs(dp[i]), Math.abs(dp[i+N-1])));
}
System.out.println(ans);
}
}