Submission #14275560
Source Code Expand
(N,K,D),A = 2.times.map{ gets.split.map(&:to_i) }
Less = lambda{|a,b|
next a[0]<b[0] || a[0]==b[0] && a[1]<b[1] ? a : b
}
L = 1<<(A.size-1).bit_length
H = [nil]*(2*L-1)
H.fill([A[-1],A.size-1],A.size-L)
A.each_with_index{|a,i|
H[i-L] = [a,i]
}
(L-2).downto(0){|i|
j = 2*i+1
H[i] = Less[H[j],H[j+1]]
}
Min = lambda{|s,e|
s = 0 if s<0
e = N-1 if N<=e
next nil if e<s
s,e = s+L-1,e+L-1
m1,m2 = H[s],H[e]
while 0
sp,ep = s/2,e/2-1
break if ep<sp
m1 = Less[m1,H[sp]]
m2 = Less[m2,H[ep]]
s,e = sp,ep
end
next Less[m1,m2]
}
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 | 707 Byte |
| Status | AC |
| Exec Time | 700 ms |
| Memory | 51032 KiB |
Compile Error
./Main.rb:29: 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 | 180 ms | 26764 KiB |
| 02.txt | AC | 134 ms | 24380 KiB |
| 03.txt | AC | 92 ms | 19044 KiB |
| 04.txt | AC | 87 ms | 20428 KiB |
| 05.txt | AC | 120 ms | 24156 KiB |
| 06.txt | AC | 206 ms | 39780 KiB |
| 07.txt | AC | 156 ms | 33456 KiB |
| 08.txt | AC | 112 ms | 23460 KiB |
| 09.txt | AC | 61 ms | 15140 KiB |
| 10.txt | AC | 159 ms | 33236 KiB |
| 11.txt | AC | 178 ms | 39152 KiB |
| 12.txt | AC | 125 ms | 23740 KiB |
| 13.txt | AC | 179 ms | 38572 KiB |
| 14.txt | AC | 175 ms | 38500 KiB |
| 15.txt | AC | 56 ms | 14156 KiB |
| 16.txt | AC | 56 ms | 14136 KiB |
| 17.txt | AC | 59 ms | 14272 KiB |
| 18.txt | AC | 70 ms | 15396 KiB |
| 19.txt | AC | 135 ms | 24340 KiB |
| 20.txt | AC | 426 ms | 43648 KiB |
| 21.txt | AC | 220 ms | 43896 KiB |
| 22.txt | AC | 259 ms | 47764 KiB |
| 23.txt | AC | 181 ms | 40344 KiB |
| 24.txt | AC | 180 ms | 40232 KiB |
| 25.txt | AC | 166 ms | 37148 KiB |
| 26.txt | AC | 124 ms | 24544 KiB |
| 27.txt | AC | 262 ms | 48008 KiB |
| 28.txt | AC | 181 ms | 40144 KiB |
| 29.txt | AC | 246 ms | 46108 KiB |
| 30.txt | AC | 205 ms | 40668 KiB |
| 31.txt | AC | 626 ms | 48308 KiB |
| 32.txt | AC | 649 ms | 48860 KiB |
| 33.txt | AC | 608 ms | 47908 KiB |
| 34.txt | AC | 504 ms | 46116 KiB |
| 35.txt | AC | 223 ms | 40976 KiB |
| 36.txt | AC | 700 ms | 51032 KiB |
| 37.txt | AC | 189 ms | 40328 KiB |
| s1.txt | AC | 56 ms | 14176 KiB |
| s2.txt | AC | 52 ms | 14228 KiB |
| s3.txt | AC | 53 ms | 14300 KiB |
| s4.txt | AC | 58 ms | 13992 KiB |