結果

問題 No.59 鉄道の旅
ユーザー cielciel
提出日時 2015-04-24 04:40:58
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 382 ms / 5,000 ms
コード長 302 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 40,204 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 05:38:53
合計ジャッジ時間 1,594 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 57 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 106 ms
4,376 KB
testcase_14 AC 382 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <cstdio>
int main(){
	std::vector<int>v;
	int N,K,n;
	scanf("%d%d",&N,&K);
	for(;N--;){
		scanf("%d",&n);
		auto it=std::lower_bound(v.begin(),v.end(),n>0?n:-n);
		if(n>0&&v.end()-it<K)v.insert(it,n);
		if(n<0&&it!=v.end()&&*it==-n)v.erase(it);
	}
	printf("%d\n",v.size());
}
0