結果

問題 No.59 鉄道の旅
ユーザー kaiyori_labkaiyori_lab
提出日時 2014-11-07 00:38:57
言語 D
(dmd 2.106.1)
結果
TLE  
実行時間 -
コード長 517 bytes
コンパイル時間 1,600 ms
コンパイル使用メモリ 92,680 KB
実行使用メモリ 11,292 KB
最終ジャッジ日時 2023-09-02 19:05:07
合計ジャッジ時間 8,865 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,872 KB
testcase_01 AC 10 ms
7,664 KB
testcase_02 AC 14 ms
6,416 KB
testcase_03 AC 61 ms
6,412 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
}
0