Please sign in first.
Submission #36331824
Source Code Expand
N,X,*A = $<.read.split.map(&:to_i)
Y = lambda{|ds| ds.inject(0){|y,d| y*10+d } }
K = lambda{|y| Y[y.digits.sort_by(&:-@)] }
YY = Hash.new{|h,k|
h[k] = k.digits.permutation.map(&Y).uniq.sort.reverse
}
S = {K[X]=>0}
S.default = -1
A.each{|a|
S.to_a.each{|k,n|
YY[k].each{|y|
break if y<a
k = K[y-a]
S[k] = n+1 if S[k]<=n
} if a<=k
}
}
p S.values.max
Submission Info
| Submission Time | |
|---|---|
| Task | B - Magical Wallet |
| User | ds14050 |
| Language | Ruby (2.7.1) |
| Score | 200 |
| Code Size | 382 Byte |
| Status | AC |
| Exec Time | 1243 ms |
| Memory | 15756 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt |
| All | 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, hand-01.txt, hand-02.txt, hand-03.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01-01.txt | AC | 885 ms | 15532 KiB |
| 01-02.txt | AC | 56 ms | 14092 KiB |
| 01-03.txt | AC | 869 ms | 15420 KiB |
| 01-04.txt | AC | 853 ms | 15576 KiB |
| 01-05.txt | AC | 922 ms | 15608 KiB |
| 01-06.txt | AC | 878 ms | 15708 KiB |
| 01-07.txt | AC | 944 ms | 15648 KiB |
| 02-01.txt | AC | 718 ms | 15756 KiB |
| 02-02.txt | AC | 58 ms | 14028 KiB |
| 02-03.txt | AC | 1243 ms | 15632 KiB |
| 02-04.txt | AC | 104 ms | 14248 KiB |
| 02-05.txt | AC | 337 ms | 15440 KiB |
| hand-01.txt | AC | 105 ms | 15416 KiB |
| hand-02.txt | AC | 55 ms | 14008 KiB |
| hand-03.txt | AC | 819 ms | 15556 KiB |
| sample-01.txt | AC | 55 ms | 14164 KiB |
| sample-02.txt | AC | 54 ms | 14004 KiB |
| sample-03.txt | AC | 55 ms | 13932 KiB |
| sample-04.txt | AC | 60 ms | 14400 KiB |