結果

問題 No.59 鉄道の旅
ユーザー dora_marutadora_maruta
提出日時 2014-11-11 16:37:00
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3,651 ms / 5,000 ms
コード長 671 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 60,916 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 05:31:06
合計ジャッジ時間 7,830 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
外部呼び出し有り
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>

int main(){
	std::vector<int> contena;
	int n, k;
	std::cin >> n >> k;
	int d = 0;
	for (int i = 0; i < n; ++i){
		int w;
		std::cin >> w;
		if (w > 0){
			int cnt = 0;
			for (auto it = contena.begin(); it != contena.end(); ++it){
				if (*it >= w)cnt++;
			}
			if (cnt < k)contena.push_back(w);
		}
		else{
			for (auto it = contena.begin(); it != contena.end(); ++it){
				if (*it == -w){
					contena.erase(it);
					break;
				}
			}
			//contena.erase(std::remove(contena.begin(), contena.end(), -w),contena.end());
		}
	}
	std::cout << contena.size() << std::endl;
	system("pause");
	return 0;
}
0