Submission #38679476
Source Code Expand
Copy
(N,M),A,C,X = $<.map{|ln| ln.split.map(&:to_i) }CM = N.times.map{|z|ms = C[0..z](z-1).downto(0){|i|ms[i] = ms[i+1] if ms[i+1]<ms[i]}next ms}X.map!{|i| i-1 }*ds = x = 0A.zip(CM).each_with_index{|(a,ms),z|ds<<10**18if X[x]==zz.downto(x).with_index{|x,y|d = ds[x]+a+ms[y]ds[x+1] = d}x += 1elsez.downto(x).with_index{|x,y|
(N,M),A,C,X = $<.map{|ln| ln.split.map(&:to_i) } CM = N.times.map{|z| ms = C[0..z] (z-1).downto(0){|i| ms[i] = ms[i+1] if ms[i+1]<ms[i] } next ms } X.map!{|i| i-1 } *ds = x = 0 A.zip(CM).each_with_index{|(a,ms),z| ds<<10**18 if X[x]==z z.downto(x).with_index{|x,y| d = ds[x]+a+ms[y] ds[x+1] = d } x += 1 else z.downto(x).with_index{|x,y| d = ds[x]+a+ms[y] ds[x+1] = d if d<ds[x+1] } end } p ds[x..].min
Submission Info
Submission Time | |
---|---|
Task | E - Wish List |
User | ds14050 |
Language | Ruby (2.7.1) |
Score | 500 |
Code Size | 465 Byte |
Status | AC |
Exec Time | 2166 ms |
Memory | 113284 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, example0.txt, example1.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 62 ms | 14004 KB |
001.txt | AC | 638 ms | 15452 KB |
002.txt | AC | 616 ms | 15060 KB |
003.txt | AC | 870 ms | 15496 KB |
004.txt | AC | 1003 ms | 113036 KB |
005.txt | AC | 2166 ms | 113132 KB |
006.txt | AC | 2106 ms | 113092 KB |
007.txt | AC | 2123 ms | 112528 KB |
008.txt | AC | 2120 ms | 113028 KB |
009.txt | AC | 1622 ms | 112592 KB |
010.txt | AC | 1695 ms | 113028 KB |
011.txt | AC | 1472 ms | 112520 KB |
012.txt | AC | 1933 ms | 113176 KB |
013.txt | AC | 1847 ms | 113080 KB |
014.txt | AC | 1615 ms | 15416 KB |
015.txt | AC | 1686 ms | 15384 KB |
016.txt | AC | 612 ms | 15308 KB |
017.txt | AC | 338 ms | 36900 KB |
018.txt | AC | 500 ms | 52928 KB |
019.txt | AC | 1032 ms | 63740 KB |
020.txt | AC | 1155 ms | 78756 KB |
021.txt | AC | 1334 ms | 88984 KB |
022.txt | AC | 1586 ms | 113144 KB |
023.txt | AC | 2031 ms | 113192 KB |
024.txt | AC | 1842 ms | 113156 KB |
025.txt | AC | 2029 ms | 113188 KB |
026.txt | AC | 1060 ms | 113152 KB |
027.txt | AC | 1291 ms | 113032 KB |
028.txt | AC | 1657 ms | 113032 KB |
029.txt | AC | 1247 ms | 113108 KB |
030.txt | AC | 1788 ms | 113020 KB |
031.txt | AC | 1098 ms | 113284 KB |
032.txt | AC | 1139 ms | 112968 KB |
033.txt | AC | 1794 ms | 112660 KB |
034.txt | AC | 1411 ms | 113136 KB |
035.txt | AC | 1621 ms | 112640 KB |
036.txt | AC | 2043 ms | 113248 KB |
037.txt | AC | 982 ms | 113052 KB |
038.txt | AC | 971 ms | 112980 KB |
039.txt | AC | 985 ms | 113092 KB |
040.txt | AC | 978 ms | 113080 KB |
041.txt | AC | 1031 ms | 113108 KB |
example0.txt | AC | 55 ms | 14076 KB |
example1.txt | AC | 55 ms | 14140 KB |