Submission #14183943
Source Code Expand
(N,K,D),A = 2.times.map{ gets.split.map(&:to_i) }
B,BL = A.map.with_index.to_a,1<<A.size.bit_length
H = [nil]*(BL-1) + B + [B[-1]]*(BL-B.size)
Less = lambda{|a,b|
next a[0]<b[0] || a[0]==b[0] && a[1]<b[1]
}
(BL-2).downto(0){|i|
j = 2*i+1
H[i] = Less[H[j+1],H[j]] ? H[j+1] : H[j]
}
Min = lambda{|s,e|
next nil if e<s || N<=s
s,e = [s,e].map{|_|(_&BL-1)+BL-1}
m1,m2 = H[s],H[e]
while 0
sp,ep = (s-1)/2,(e-1)/2
sp += s&1^1
ep -= e&1
break if ep<sp
m1 = H[sp] if Less[H[sp],m1]
m2 = H[ep] if Less[H[ep],m2]
s,e = sp,ep
end if s<e
next Less[m2,m1] ? m2 : m1
}
c,C = -D,[]
K.downto(1){|k|
m,i = Min[c+D, N-1-D*(k-1)]
break unless m
C << m
c = i
}
puts(C.size==K ? C.join(" ") : -1)
Submission Info
| Submission Time | |
|---|---|
| Task | L - Lexicographically Minimum |
| User | ds14050 |
| Language | Ruby (2.7.1) |
| Score | 6 |
| Code Size | 740 Byte |
| Status | AC |
| Exec Time | 870 ms |
| Memory | 61964 KiB |
Compile Error
./Main.rb:24: warning: literal in condition
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 6 / 6 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | s1.txt, s2.txt, s3.txt, s4.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, s1.txt, s2.txt, s3.txt, s4.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | AC | 187 ms | 34908 KiB |
| 02.txt | AC | 144 ms | 32252 KiB |
| 03.txt | AC | 95 ms | 20612 KiB |
| 04.txt | AC | 84 ms | 22784 KiB |
| 05.txt | AC | 127 ms | 32896 KiB |
| 06.txt | AC | 207 ms | 48016 KiB |
| 07.txt | AC | 152 ms | 41624 KiB |
| 08.txt | AC | 110 ms | 29216 KiB |
| 09.txt | AC | 66 ms | 16680 KiB |
| 10.txt | AC | 151 ms | 41352 KiB |
| 11.txt | AC | 174 ms | 48932 KiB |
| 12.txt | AC | 130 ms | 31976 KiB |
| 13.txt | AC | 170 ms | 48220 KiB |
| 14.txt | AC | 172 ms | 48004 KiB |
| 15.txt | AC | 56 ms | 14076 KiB |
| 16.txt | AC | 51 ms | 14336 KiB |
| 17.txt | AC | 56 ms | 14696 KiB |
| 18.txt | AC | 66 ms | 16756 KiB |
| 19.txt | AC | 146 ms | 32004 KiB |
| 20.txt | AC | 481 ms | 57844 KiB |
| 21.txt | AC | 226 ms | 58532 KiB |
| 22.txt | AC | 282 ms | 60908 KiB |
| 23.txt | AC | 178 ms | 49572 KiB |
| 24.txt | AC | 177 ms | 49428 KiB |
| 25.txt | AC | 164 ms | 46048 KiB |
| 26.txt | AC | 123 ms | 34480 KiB |
| 27.txt | AC | 287 ms | 61964 KiB |
| 28.txt | AC | 176 ms | 49684 KiB |
| 29.txt | AC | 265 ms | 60624 KiB |
| 30.txt | AC | 215 ms | 51172 KiB |
| 31.txt | AC | 776 ms | 61268 KiB |
| 32.txt | AC | 811 ms | 61108 KiB |
| 33.txt | AC | 760 ms | 61072 KiB |
| 34.txt | AC | 626 ms | 60444 KiB |
| 35.txt | AC | 228 ms | 51588 KiB |
| 36.txt | AC | 870 ms | 60980 KiB |
| 37.txt | AC | 191 ms | 50332 KiB |
| s1.txt | AC | 51 ms | 14208 KiB |
| s2.txt | AC | 52 ms | 14032 KiB |
| s3.txt | AC | 51 ms | 14116 KiB |
| s4.txt | AC | 53 ms | 14172 KiB |