結果

問題 No.59 鉄道の旅
ユーザー face4face4
提出日時 2018-09-26 14:07:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 453 bytes
コンパイル時間 734 ms
コンパイル使用メモリ 71,508 KB
実行使用メモリ 11,808 KB
最終ジャッジ日時 2024-04-18 17:44:27
合計ジャッジ時間 7,420 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 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 #

#include<iostream>
#include<set>
using namespace std;

int main(){
    int n, k, w;
    multiset<int> s;

    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> w;
        if(w > 0){
            int bring = distance(s.lower_bound(w), s.end());
            if(bring < k)   s.insert(w);
        }else{
            auto it = s.find(-w);
            if(it != s.end())   s.erase(it);
        }
    }

    cout << s.size() << endl;

    return 0;
}
0