結果

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

テストケース

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

ソースコード

diff #

#include <vector>
#include <cstdio>
int main(){
	std::vector<int>v;
	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=std::lower_bound(v.begin(),v.end(),n);
			if(std::distance(it,v.end())<K)v.insert(it,n);
		}else{
			auto it=std::lower_bound(v.begin(),v.end(),-n);
			if(*it==-n)v.erase(it);
		}
	}
	printf("%d\n",v.size());
}
0