結果
| 問題 | No.59 鉄道の旅 | 
| コンテスト | |
| ユーザー |  kaiyori_lab | 
| 提出日時 | 2014-11-07 00:38:57 | 
| 言語 | D (dmd 2.109.1) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 517 bytes | 
| コンパイル時間 | 725 ms | 
| コンパイル使用メモリ | 103,124 KB | 
| 実行使用メモリ | 13,732 KB | 
| 最終ジャッジ日時 | 2024-06-12 01:30:27 | 
| 合計ジャッジ時間 | 7,718 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | TLE * 1 -- * 11 | 
ソースコード
import std.stdio;
import std.conv;
import std.string;
import std.math;
import std.algorithm;
void main(){
	auto nk = readln.split.map!(to!int);
	int[] numMemo; numMemo.length = 1_000_005;
	int wi;
	int wiCount(int j){ return numMemo[j..$].reduce!("a + b"); }
	foreach(i; 1..nk[0]+1){
		wi = readln.chomp.to!int;
		if(wi > 0){
			if(wiCount(wi) < nk[1] ){ numMemo[wi] += 1; }
		}
		else{ numMemo[abs(wi)] = max(0, numMemo[abs(wi)] - 1); }
	}
	auto res = numMemo.reduce!("a + b");
	res.writeln;
}
            
            
            
        