Submission #51185273


Source Code Expand

$In = $<.map{|ln| ln.split.map(&:to_i) }
N, = $In.shift
P = $In.shift N
R = $In.shift(N).map{_1<<0}
D = $In<<[0]*N
P00 = P[0][0]

待機数残コスト = Array.new(N){[]}
待機数残コスト[0]<<[0,0]
N.times{
	ps = P.pop
	rs = R.pop
	ds = D.pop
	sc0r = []
	待機数残コスト.map!{|sc0d|
		p = ps.pop
		r = rs.pop
		d = ds.pop
		s0,c0 = -1,1.0/0
		sc = (sc0d.flat_map{|s,c|
			c += d
			next [s,c],[s+c/p,c%p],[s+(c+p-1)/p,0]
		}+sc0r.flat_map{|s,c|
			c += r
			next [s,c],[s+c/p,c%p],[s+(c+p-1)/p,0]
		}).sort_by{_1<<40|_2}.select{|s,c|
			s0,c0 = s,c if s0<s && c<c0
		}
		next sc0r = sc
	}
}

p 待機数残コスト[-1].map{|s,c| s+(c+P00-1)/P00 }.min+N+N-2

Submission Info

Submission Time
Task F - Earn to Advance
User ds14050
Language Ruby (ruby 3.2.2)
Score 550
Code Size 702 Byte
Status AC
Exec Time 2167 ms
Memory 21372 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 550 / 550
Status
AC × 2
AC × 31
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
min.txt AC 129 ms 17200 KiB
random_01.txt AC 272 ms 20916 KiB
random_02.txt AC 170 ms 20580 KiB
random_03.txt AC 1935 ms 21132 KiB
random_04.txt AC 363 ms 20816 KiB
random_05.txt AC 282 ms 21036 KiB
random_06.txt AC 283 ms 21080 KiB
random_07.txt AC 2167 ms 21080 KiB
random_08.txt AC 92 ms 19824 KiB
random_09.txt AC 277 ms 21028 KiB
random_10.txt AC 1812 ms 21128 KiB
random_11.txt AC 267 ms 20740 KiB
random_12.txt AC 1779 ms 21152 KiB
random_13.txt AC 288 ms 21344 KiB
random_14.txt AC 2049 ms 20904 KiB
random_15.txt AC 266 ms 21104 KiB
random_16.txt AC 2075 ms 21004 KiB
random_17.txt AC 233 ms 21008 KiB
random_18.txt AC 65 ms 18424 KiB
random_19.txt AC 1521 ms 21100 KiB
random_20.txt AC 1468 ms 20832 KiB
random_21.txt AC 230 ms 20988 KiB
random_22.txt AC 133 ms 20312 KiB
random_23.txt AC 1650 ms 21044 KiB
random_24.txt AC 1208 ms 20896 KiB
random_25.txt AC 711 ms 21372 KiB
random_26.txt AC 1622 ms 20624 KiB
random_27.txt AC 68 ms 18480 KiB
random_28.txt AC 711 ms 21144 KiB
sample_01.txt AC 43 ms 17724 KiB
sample_02.txt AC 42 ms 17676 KiB