結果
| 問題 | No.59 鉄道の旅 | 
| コンテスト | |
| ユーザー |  ano184 | 
| 提出日時 | 2014-11-08 03:39:55 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,045 bytes | 
| コンパイル時間 | 865 ms | 
| コンパイル使用メモリ | 75,852 KB | 
| 実行使用メモリ | 7,552 KB | 
| 最終ジャッジ日時 | 2024-12-24 20:21:54 | 
| 合計ジャッジ時間 | 1,846 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 11 RE * 1 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
#define rep(x,to) for(int (x)=(0);(x)<(to);(x)++)
#define repf(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
using namespace std;
const int MX=1000000;
int zmp[MX+10];
int main()
{
	int n, k;
	const int gsz=200;
	cin >> n >>k;
	vector<int> w(n);
	repf(i,0,n) cin >>w[i];
	//map<unsigned int,int> zmp;
	vector<int> ct(*max_element(w.begin(), w.end())/gsz+2,0);
	repf(i,0,n){
		int q=w[i];
		if(q>=0){
			int nxs= q/gsz +1;
			int c = accumulate(ct.begin()+nxs,ct.end(),0);
			//auto it=zmp.lower_bound(q);
			//for(;it != zmp.end() && it->first<nxs*gsz;it++) c+=it->second;
			c += accumulate(zmp+q, zmp+min(MX+1,nxs*gsz),0);
			if(c<k) zmp[q]++,  ct[q/gsz]++;
		}else{
			if(zmp[-q]>0) zmp[-q]--, ct[-q/gsz]--; 
		}
	}
	
	cout << accumulate(ct.begin(),ct.end(),0) << endl;
	
	return 0;
}
            
            
            
        