結果

問題 No.370 道路の掃除
ユーザー 37zigen37zigen
提出日時 2016-05-13 23:39:19
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 674 bytes
コンパイル時間 2,132 ms
コンパイル使用メモリ 75,236 KB
実行使用メモリ 54,704 KB
最終ジャッジ日時 2024-04-15 17:19:18
合計ジャッジ時間 8,141 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
54,308 KB
testcase_01 AC 124 ms
54,096 KB
testcase_02 AC 126 ms
54,116 KB
testcase_03 AC 131 ms
54,192 KB
testcase_04 AC 130 ms
54,200 KB
testcase_05 AC 124 ms
54,376 KB
testcase_06 AC 124 ms
53,956 KB
testcase_07 AC 123 ms
53,796 KB
testcase_08 AC 115 ms
53,576 KB
testcase_09 AC 122 ms
54,300 KB
testcase_10 AC 132 ms
54,380 KB
testcase_11 AC 136 ms
54,444 KB
testcase_12 AC 140 ms
54,572 KB
testcase_13 AC 135 ms
54,396 KB
testcase_14 AC 132 ms
54,272 KB
testcase_15 AC 126 ms
54,352 KB
testcase_16 AC 135 ms
54,512 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 137 ms
54,060 KB
testcase_20 AC 183 ms
54,264 KB
testcase_21 AC 166 ms
54,344 KB
testcase_22 AC 158 ms
54,620 KB
testcase_23 AC 173 ms
54,244 KB
testcase_24 AC 141 ms
54,248 KB
testcase_25 AC 164 ms
54,432 KB
testcase_26 AC 181 ms
54,704 KB
testcase_27 AC 156 ms
54,380 KB
testcase_28 AC 166 ms
54,476 KB
testcase_29 AC 173 ms
54,284 KB
testcase_30 AC 180 ms
54,296 KB
testcase_31 AC 169 ms
54,376 KB
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int[] d=new int[m];
		int min_d=999999999;
		for(int i=0;i<m;i++){
			d[i]=sc.nextInt();
		}
		Arrays.sort(d);
		for(int i=0;i+n<m;i++){
			min_d=Math.min(min_d, calc(d[i],d[i+n-1]));
		}
		System.out.println(min_d);
	}
	int calc(int left,int right){
		if(left<=0&&right<=0)return -left;
		if(left<0&&right>0)return Math.min(-2*left+right,-left+2*right);
		if(left>=0&&right>0)return right;
		else return -1;//error
	}
}
0