結果

問題 No.59 鉄道の旅
ユーザー ayame_pyayame_py
提出日時 2016-02-09 17:02:31
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 951 bytes
コンパイル時間 1,529 ms
コンパイル使用メモリ 146,976 KB
実行使用メモリ 9,304 KB
最終ジャッジ日時 2023-08-26 06:54:03
合計ジャッジ時間 7,762 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,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 <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007
#define all(a) (a).begin(),(a).end()


typedef long long ll;
typedef pair<int,int> p;
typedef pair<p,int> pv;

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};


int N,K;
int main(){
    ios::sync_with_stdio(false);
    cin >> N >> K;
    multiset<int> train;
    REP(i,N){
        int t;
        cin >> t;
        int cnt=0;
        //おろす
        if(t<0){
            t=-t;
            auto it=train.lower_bound(t);
            if(it==train.end()) continue;
            if(*it==t) train.erase(it);
        }
        //つむ
        else{
            auto it=train.lower_bound(t);
            int tmp=distance(it,train.end());
            if(K-1<tmp) continue;
            train.insert(t);
        }
    }
    
    cout << train.size() << endl;
    
    return 0;
}
0