結果

問題 No.59 鉄道の旅
ユーザー dora_maruta
提出日時 2014-11-11 16:49:11
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 698 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 59,384 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-12-24 20:23:36
合計ジャッジ時間 14,572 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 2 WA * 9 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>

int contena[1000001];

int main(){
	//std::vector<int> contena;
	int n, k;
	std::cin >> n >> k;
	int m = 0;
	int d = 0;
	for (int i = 0; i < n; ++i){
		int w;
		std::cin >> w;
		m = std::max(m, w);
		if (w > 0){
			int cnt = 0;
			for (int j = m; j >w; --j){
				if (contena[j] != 0)cnt+=contena[j];
			}
			if (cnt < k)contena[w]++;
		}
		else{
			if (contena[-w] != 0)contena[-w]--;
			//contena.erase(std::remove(contena.begin(), contena.end(), -w),contena.end());
		}
	}
	int ans = 0;
	for (int i = 1; i < m; ++i){
		if (contena[i] != 0)ans += contena[i];
	}
	std::cout << ans << std::endl;
	return 0;
}
0