結果
| 問題 | No.59 鉄道の旅 | 
| コンテスト | |
| ユーザー |  chaemon | 
| 提出日時 | 2014-11-06 23:27:14 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,533 bytes | 
| コンパイル時間 | 780 ms | 
| コンパイル使用メモリ | 82,668 KB | 
| 実行使用メモリ | 10,112 KB | 
| 最終ジャッジ日時 | 2024-12-24 19:56:40 | 
| 合計ジャッジ時間 | 20,283 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 4 WA * 5 TLE * 3 | 
ソースコード
// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define EXIST(e,s) ((s).find(e)!=(s).end())
#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command
const int INF=0x3f3f3f3f;
typedef long long Int;
typedef unsigned long long uInt;
#ifdef __MINGW32__
typedef double rn;
#else
typedef long double rn;
#endif
typedef pair<int,int> pii;
/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}
int N,K;
int main(){
	cin>>N>>K;
	multiset<int> s;
	REP(i,N){
		int W;
		cin>>W;
		if(W<0){
			W*=-1;
			if(EXIST(W,s))s.erase(W);
		}else{
			multiset<int>::iterator it = s.lower_bound(W);
			if(distance(it,s.end())<K){
				s.insert(W);
			}
		}
	}
	cout<<s.size()<<endl;
	return 0;
}
            
            
            
        