結果
問題 | No.59 鉄道の旅 |
ユーザー | kyuridenamida |
提出日時 | 2016-02-18 01:41:31 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 113 ms / 5,000 ms |
コード長 | 933 bytes |
コンパイル時間 | 3,087 ms |
コンパイル使用メモリ | 188,876 KB |
実行使用メモリ | 9,472 KB |
最終ジャッジ日時 | 2024-12-24 22:08:01 |
合計ジャッジ時間 | 4,162 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #include<ext/pb_ds/tag_and_trait.hpp> using namespace __gnu_pbds; using namespace std; #define rep(i,n) for(int (i) = 0 ; (i) < (int)(n) ; (i)++) #define REP(i,a,b) for(int (i) = a ; (int)(i) <= (int)(b) ; (i)++) #define all(n) (n).begin(),(n).end() typedef long long ll; typedef vector<int> Vi; typedef vector<Vi> VVi; typedef pair<long long,long long> Pii; typedef vector<Pii> VPii; typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> set2; int main(){ int N,K; cin >> N >> K; set2 S; rep(i,N){ int W; cin >> W; if( W > 0 ){ int num = S.size() - S.order_of_key({W,-1}); if( num < K ){ S.insert({W,i}); } }else{ W = -W; auto key = S.lower_bound({W,-1}); if( key != S.end() && key->first == W ) S.erase(*key); } } cout << S.size() << endl; }