結果

問題 No.59 鉄道の旅
コンテスト
ユーザー ciel
提出日時 2015-04-24 03:54:59
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 343 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 374 ms
コンパイル使用メモリ 56,448 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2026-05-30 15:11:43
合計ジャッジ時間 7,228 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other TLE * 1 -- * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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