結果

問題 No.370 道路の掃除
ユーザー yun_appyun_app
提出日時 2016-05-17 10:14:19
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,172 bytes
コンパイル時間 2,456 ms
コンパイル使用メモリ 78,524 KB
実行使用メモリ 37,232 KB
最終ジャッジ日時 2024-04-15 22:46:23
合計ジャッジ時間 5,607 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
36,900 KB
testcase_01 AC 55 ms
36,816 KB
testcase_02 AC 55 ms
36,664 KB
testcase_03 AC 53 ms
36,692 KB
testcase_04 AC 57 ms
37,016 KB
testcase_05 AC 55 ms
37,000 KB
testcase_06 AC 55 ms
36,992 KB
testcase_07 AC 54 ms
37,036 KB
testcase_08 AC 54 ms
37,176 KB
testcase_09 AC 57 ms
36,864 KB
testcase_10 AC 54 ms
36,904 KB
testcase_11 AC 57 ms
36,636 KB
testcase_12 AC 55 ms
36,960 KB
testcase_13 AC 58 ms
36,604 KB
testcase_14 AC 56 ms
36,500 KB
testcase_15 AC 57 ms
37,032 KB
testcase_16 AC 55 ms
36,780 KB
testcase_17 AC 56 ms
36,956 KB
testcase_18 AC 58 ms
36,972 KB
testcase_19 AC 59 ms
37,056 KB
testcase_20 AC 62 ms
36,756 KB
testcase_21 AC 58 ms
36,944 KB
testcase_22 AC 57 ms
36,964 KB
testcase_23 AC 59 ms
37,224 KB
testcase_24 AC 56 ms
36,988 KB
testcase_25 AC 57 ms
36,736 KB
testcase_26 AC 58 ms
37,108 KB
testcase_27 AC 58 ms
36,992 KB
testcase_28 AC 60 ms
36,908 KB
testcase_29 AC 62 ms
37,156 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int N = Integer.parseInt(line[0]);
        int M = Integer.parseInt(line[1]);
        
        ArrayList<Integer> gomi = new ArrayList<Integer>();
        for(int i=0;i<M;i++){
            gomi.add(Integer.parseInt(br.readLine()));
        }
        
        int ans = Integer.MAX_VALUE;
        for(int i=0;i<M-N+1;i++){
            int sum = 0;
            if((gomi.get(i) < 0 && gomi.get(i+N-1) > 0) 
            || (gomi.get(i) > 0 && gomi.get(i+N-1) < 0)){
                sum += 2*Math.min(Math.abs(gomi.get(i)),Math.abs(gomi.get(i+N-1)));
            }
            sum += Math.max(Math.abs(gomi.get(i)),Math.abs(gomi.get(i+N-1)));
            ans = Math.min(ans,sum);
        }
        System.out.println(ans);
    }
}
0