結果

問題 No.59 鉄道の旅
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-12-10 05:38:08
言語 Java19
(openjdk 21)
結果
TLE  
実行時間 -
コード長 699 bytes
コンパイル時間 2,006 ms
コンパイル使用メモリ 71,532 KB
実行使用メモリ 74,472 KB
最終ジャッジ日時 2023-08-26 08:01:33
合計ジャッジ時間 18,449 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
64,316 KB
testcase_01 AC 125 ms
59,956 KB
testcase_02 AC 128 ms
60,268 KB
testcase_03 AC 135 ms
60,220 KB
testcase_04 AC 4,406 ms
70,120 KB
testcase_05 AC 165 ms
60,084 KB
testcase_06 AC 169 ms
60,176 KB
testcase_07 AC 157 ms
60,588 KB
testcase_08 AC 1,253 ms
70,044 KB
testcase_09 AC 1,039 ms
70,188 KB
testcase_10 AC 774 ms
68,868 KB
testcase_11 AC 235 ms
64,144 KB
testcase_12 AC 475 ms
64,636 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int [] c = new int [1000001];
        for(int i=0; i<N; i++){
            int W = sc.nextInt();
            if(W>0){
                if(c[W]<K){
                    for(int j=W; j>=0; j--){
                        c[j]++;
                    }
                }
            }else{
                if(c[1-W]-c[-W]<0){
                    for(int j=-W; j>=0; j--){
                        c[j]--;
                    }
                }
            }
        }
        System.out.println(c[0]);
    }
}
0