結果

問題 No.59 鉄道の旅
ユーザー cielciel
提出日時 2015-04-24 03:54:59
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 343 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 39,756 KB
実行使用メモリ 8,880 KB
最終ジャッジ日時 2023-08-26 05:38:30
合計ジャッジ時間 6,767 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 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 <set>
#include <cstdio>
int main(){
	std::multiset<int>se;
	int N,K;
	scanf("%d%d",&N,&K);
	for(int i=0;i<N;i++){
		int n;
		scanf("%d",&n);
		if(n>0){
			auto it=se.lower_bound(n);
			if(std::distance(it,se.end())<K)se.insert(n);
		}else{
			auto it=se.lower_bound(-n);
			if(*it==-n)se.erase(it);
		}
	}
	printf("%d\n",se.size());
}
0