結果

問題 No.448 ゆきこーだーの雨と雪 (3)
ユーザー cielciel
提出日時 2016-11-23 01:33:05
言語 Ruby
(3.3.0)
結果
AC  
実行時間 774 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 11,544 KB
実行使用メモリ 33,176 KB
最終ジャッジ日時 2023-09-02 12:58:00
合計ジャッジ時間 15,146 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,256 KB
testcase_01 AC 78 ms
15,048 KB
testcase_02 AC 78 ms
15,036 KB
testcase_03 AC 79 ms
15,324 KB
testcase_04 AC 82 ms
15,140 KB
testcase_05 AC 81 ms
15,148 KB
testcase_06 AC 83 ms
15,152 KB
testcase_07 AC 81 ms
15,156 KB
testcase_08 AC 81 ms
15,036 KB
testcase_09 AC 80 ms
15,260 KB
testcase_10 AC 81 ms
15,220 KB
testcase_11 AC 83 ms
15,228 KB
testcase_12 AC 84 ms
15,292 KB
testcase_13 AC 168 ms
17,440 KB
testcase_14 AC 165 ms
17,556 KB
testcase_15 AC 308 ms
22,644 KB
testcase_16 AC 436 ms
28,004 KB
testcase_17 AC 472 ms
28,620 KB
testcase_18 AC 147 ms
16,812 KB
testcase_19 AC 631 ms
31,896 KB
testcase_20 AC 274 ms
22,312 KB
testcase_21 AC 673 ms
32,304 KB
testcase_22 AC 286 ms
22,396 KB
testcase_23 AC 562 ms
32,128 KB
testcase_24 AC 205 ms
19,616 KB
testcase_25 AC 659 ms
31,888 KB
testcase_26 AC 137 ms
16,548 KB
testcase_27 AC 442 ms
28,044 KB
testcase_28 AC 469 ms
26,996 KB
testcase_29 AC 273 ms
22,580 KB
testcase_30 AC 625 ms
32,324 KB
testcase_31 AC 152 ms
17,316 KB
testcase_32 AC 153 ms
17,456 KB
testcase_33 AC 683 ms
33,168 KB
testcase_34 AC 671 ms
33,176 KB
testcase_35 AC 612 ms
33,132 KB
testcase_36 AC 648 ms
32,988 KB
testcase_37 AC 774 ms
32,916 KB
testcase_38 AC 654 ms
33,128 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/usr/bin/ruby
n,k=gets.split.map(&:to_i)
a=$<.map{|e|e.split.map(&:to_i)}
p ma=(0..10**9).bsearch{|e|
	tail=-k
	!!a.each{|t,d|
		if d>e
			if t-tail<k
				break
			else
				tail=t
			end
		end
	}
}
t,d=a.transpose
ng=[false]*n
tail=t[-1]+k
(n-1).downto(s=0){|i|
	if d[i]>ma
		tail=t[i]
	elsif tail-t[i]<k
		ng[i]=true
	end
}
m=[j=0]
tail=-k
n.times{|i|
	if d[i]>ma
		tail=t[i]
	elsif t[i]-tail<k
		ng[i]=true
	end
}
n.times{|i|
	if d[i]>ma
		d[i]=0
	else
		s+=d[i]
		d[i]=0 if ng[i]
	end
	j+=1 while t[i]-t[j]>=k
	m[i+1]=[m[i],m[j]+d[i]].max
}
p s-m[n]
0