結果

問題 No.448 ゆきこーだーの雨と雪 (3)
ユーザー cielciel
提出日時 2016-11-23 01:14:46
言語 Ruby
(3.3.0)
結果
AC  
実行時間 870 ms / 2,000 ms
コード長 619 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 11,464 KB
実行使用メモリ 30,216 KB
最終ジャッジ日時 2023-09-02 12:56:22
合計ジャッジ時間 18,138 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,220 KB
testcase_01 AC 85 ms
15,140 KB
testcase_02 AC 83 ms
15,164 KB
testcase_03 AC 83 ms
15,144 KB
testcase_04 AC 85 ms
15,076 KB
testcase_05 AC 87 ms
15,152 KB
testcase_06 AC 88 ms
15,184 KB
testcase_07 AC 86 ms
15,296 KB
testcase_08 AC 87 ms
15,156 KB
testcase_09 AC 86 ms
15,104 KB
testcase_10 AC 86 ms
14,988 KB
testcase_11 AC 87 ms
15,236 KB
testcase_12 AC 87 ms
15,244 KB
testcase_13 AC 174 ms
16,908 KB
testcase_14 AC 174 ms
17,232 KB
testcase_15 AC 341 ms
21,356 KB
testcase_16 AC 487 ms
26,068 KB
testcase_17 AC 537 ms
26,348 KB
testcase_18 AC 157 ms
16,516 KB
testcase_19 AC 742 ms
29,148 KB
testcase_20 AC 301 ms
21,472 KB
testcase_21 AC 746 ms
29,108 KB
testcase_22 AC 319 ms
21,368 KB
testcase_23 AC 635 ms
29,224 KB
testcase_24 AC 223 ms
18,780 KB
testcase_25 AC 739 ms
29,212 KB
testcase_26 AC 143 ms
16,368 KB
testcase_27 AC 490 ms
26,008 KB
testcase_28 AC 519 ms
25,024 KB
testcase_29 AC 300 ms
21,156 KB
testcase_30 AC 718 ms
29,452 KB
testcase_31 AC 163 ms
16,804 KB
testcase_32 AC 168 ms
17,144 KB
testcase_33 AC 819 ms
29,940 KB
testcase_34 AC 870 ms
30,084 KB
testcase_35 AC 710 ms
30,152 KB
testcase_36 AC 697 ms
30,080 KB
testcase_37 AC 828 ms
30,216 KB
testcase_38 AC 744 ms
30,112 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
	}
}
ng=[false]*n
tail=-k
0.upto(n-1){|i|
	if a[i][1]>ma
		tail=a[i][0]
	elsif a[i][0]-tail<k
		ng[i]=true
	end
}
tail=a[-1][0]+k
(n-1).downto(0){|i|
	if a[i][1]>ma
		tail=a[i][0]
	elsif tail-a[i][0]<k
		ng[i]=true
	end
}
s=0
n.times{|i|
	if a[i][1]>ma
		a[i][1]=0
	else
		s+=a[i][1]
		a[i][1]=0 if ng[i]
	end
}
dp=[0]
t=x=0
n.times{|i|
	t=[t,dp[x+=1]].max while a[i][0]-a[x][0]>=k
	dp[i+1]=[dp[i],t+a[i][1]].max
}
p s-dp[n]
0