Submission #51204120


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

待機数残コスト = 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.0/0
		next sc0r = (sc0r.flat_map{|s,c|
			c += r
			next [s,c],[s+c/p,c%p],[s+(c+p-1)/p,0]
		}+sc0d.flat_map{|s,c|
			c += d
			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 && ((s-s0)*p<=c0-c || c==0)
		}
	}
}

p 待機数残コスト[-1][-1][0]+N+N-2

Submission Info

Submission Time
Task F - Earn to Advance
User ds14050
Language Ruby (ruby 3.2.2)
Score 550
Code Size 679 Byte
Status AC
Exec Time 1666 ms
Memory 21328 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 120 ms 17268 KiB
random_01.txt AC 163 ms 20600 KiB
random_02.txt AC 112 ms 19708 KiB
random_03.txt AC 213 ms 20496 KiB
random_04.txt AC 91 ms 18584 KiB
random_05.txt AC 163 ms 20436 KiB
random_06.txt AC 156 ms 20360 KiB
random_07.txt AC 221 ms 20528 KiB
random_08.txt AC 56 ms 17760 KiB
random_09.txt AC 159 ms 20672 KiB
random_10.txt AC 209 ms 20608 KiB
random_11.txt AC 150 ms 20192 KiB
random_12.txt AC 211 ms 20496 KiB
random_13.txt AC 165 ms 20788 KiB
random_14.txt AC 234 ms 20572 KiB
random_15.txt AC 154 ms 20468 KiB
random_16.txt AC 258 ms 20708 KiB
random_17.txt AC 93 ms 18504 KiB
random_18.txt AC 57 ms 17864 KiB
random_19.txt AC 175 ms 19872 KiB
random_20.txt AC 174 ms 19852 KiB
random_21.txt AC 94 ms 18492 KiB
random_22.txt AC 73 ms 18332 KiB
random_23.txt AC 169 ms 19940 KiB
random_24.txt AC 142 ms 19488 KiB
random_25.txt AC 755 ms 21328 KiB
random_26.txt AC 1666 ms 20744 KiB
random_27.txt AC 74 ms 18488 KiB
random_28.txt AC 751 ms 21300 KiB
sample_01.txt AC 46 ms 17728 KiB
sample_02.txt AC 47 ms 17664 KiB