結果

問題 No.448 ゆきこーだーの雨と雪 (3)
ユーザー cielciel
提出日時 2016-11-23 01:35:00
言語 Ruby
(3.3.0)
結果
AC  
実行時間 710 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 11,312 KB
実行使用メモリ 33,272 KB
最終ジャッジ日時 2023-09-02 12:58:16
合計ジャッジ時間 14,087 ms
ジャッジサーバーID
(参考情報)
judge16 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,172 KB
testcase_01 AC 81 ms
15,236 KB
testcase_02 AC 78 ms
15,192 KB
testcase_03 AC 76 ms
15,084 KB
testcase_04 AC 78 ms
15,080 KB
testcase_05 AC 80 ms
15,184 KB
testcase_06 AC 78 ms
15,232 KB
testcase_07 AC 80 ms
15,136 KB
testcase_08 AC 79 ms
15,224 KB
testcase_09 AC 79 ms
15,184 KB
testcase_10 AC 81 ms
15,132 KB
testcase_11 AC 81 ms
15,112 KB
testcase_12 AC 80 ms
15,044 KB
testcase_13 AC 158 ms
17,196 KB
testcase_14 AC 159 ms
17,620 KB
testcase_15 AC 294 ms
22,796 KB
testcase_16 AC 413 ms
28,008 KB
testcase_17 AC 447 ms
28,524 KB
testcase_18 AC 139 ms
16,848 KB
testcase_19 AC 619 ms
31,756 KB
testcase_20 AC 257 ms
22,312 KB
testcase_21 AC 635 ms
31,892 KB
testcase_22 AC 271 ms
22,380 KB
testcase_23 AC 537 ms
32,012 KB
testcase_24 AC 196 ms
19,548 KB
testcase_25 AC 638 ms
32,024 KB
testcase_26 AC 131 ms
16,716 KB
testcase_27 AC 421 ms
27,840 KB
testcase_28 AC 447 ms
27,072 KB
testcase_29 AC 256 ms
22,460 KB
testcase_30 AC 586 ms
32,116 KB
testcase_31 AC 145 ms
17,224 KB
testcase_32 AC 149 ms
17,712 KB
testcase_33 AC 694 ms
32,920 KB
testcase_34 AC 682 ms
33,132 KB
testcase_35 AC 609 ms
33,272 KB
testcase_36 AC 587 ms
33,140 KB
testcase_37 AC 710 ms
32,880 KB
testcase_38 AC 606 ms
33,044 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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
		d[i]=0
		tail=t[i]
	else
		s+=d[i]
		d[i]=0 if ng[i]||t[i]-tail<k
	end
	j+=1 while t[i]-t[j]>=k
	m[i+1]=[m[i],m[j]+d[i]].max
}
p s-m[n]
0