結果

問題 No.59 鉄道の旅
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2017-01-21 20:57:33
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 741 bytes
コンパイル時間 3,474 ms
コンパイル使用メモリ 71,984 KB
実行使用メモリ 66,992 KB
最終ジャッジ日時 2023-08-26 16:35:35
合計ジャッジ時間 10,926 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
66,992 KB
testcase_01 AC 145 ms
60,148 KB
testcase_02 AC 147 ms
59,688 KB
testcase_03 AC 162 ms
59,932 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
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){
                int tmp=0;
                for(int j=W; j<1000001; j++){
                    tmp+=c[j];
                }
                if(tmp<K){
                    c[W]++;
                }
            }else{
                W*=-1;
                if(c[W]>0)c[W]--;
            }
        }
        int ans=0;
        for(int j=0; j<1000001; j++){
            ans+=c[j];
        }
        System.out.println(ans);
    }
}
0