結果

問題 No.59 鉄道の旅
コンテスト
ユーザー kohaku_kohaku
提出日時 2017-01-21 20:57:33
言語 Java
(openjdk 27 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
TLE  
実行時間 -
コード長 741 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,449 ms
コンパイル使用メモリ 84,988 KB
実行使用メモリ 62,732 KB
最終ジャッジ日時 2026-10-07 19:47:30
合計ジャッジ時間 27,247 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7 TLE * 2 -- * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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