Submission #993577
Source Code Expand
#!/usr/bin/ruby N,M,*X=`dd`.split.map(&:to_i) h=Hash.new{|h,k|h[k]=[]} X.each{|e| h[e%M]<<e } r=0 pairs=[0]*M (0..M/2).each{|i| opp=M-i opp=0 if opp==M if i==opp npairs=h[i].size/2 pairs[i]=npairs*2 r+=npairs else npairs=[h[i].size,h[opp].size].min pairs[i]=pairs[opp]=npairs r+=npairs end } (0...M).each{|i| s=h[i].group_by{|e|e}.reduce(0){|s,(k,v)|s+v.size/2} r+=[(h[i].size-pairs[i])/2,s].min } p r
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | leafmoon |
Language | Ruby (2.3.3) |
Score | 700 |
Code Size | 446 Byte |
Status | AC |
Exec Time | 366 ms |
Memory | 28032 KB |
Compile Error
./Main.rb:3: warning: shadowing outer local variable - h ./Main.rb:23: warning: shadowing outer local variable - s ./Main.rb:23: warning: assigned but unused variable - k
Judge Result
Set Name | sample | all | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 700 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt |
all | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 19 ms | 2164 KB |
01-02.txt | AC | 126 ms | 19348 KB |
01-03.txt | AC | 123 ms | 17848 KB |
01-04.txt | AC | 120 ms | 15336 KB |
01-05.txt | AC | 120 ms | 15636 KB |
01-06.txt | AC | 117 ms | 14864 KB |
01-07.txt | AC | 117 ms | 14736 KB |
01-08.txt | AC | 117 ms | 14740 KB |
01-09.txt | AC | 120 ms | 14740 KB |
01-10.txt | AC | 220 ms | 24720 KB |
01-11.txt | AC | 340 ms | 27392 KB |
01-12.txt | AC | 81 ms | 10648 KB |
01-13.txt | AC | 169 ms | 21580 KB |
01-14.txt | AC | 139 ms | 23812 KB |
01-15.txt | AC | 133 ms | 18064 KB |
01-16.txt | AC | 127 ms | 14476 KB |
01-17.txt | AC | 128 ms | 14744 KB |
01-18.txt | AC | 138 ms | 14608 KB |
01-19.txt | AC | 160 ms | 16152 KB |
01-20.txt | AC | 366 ms | 28032 KB |
01-21.txt | AC | 89 ms | 11552 KB |
01-22.txt | AC | 88 ms | 11664 KB |
01-23.txt | AC | 87 ms | 11664 KB |
01-24.txt | AC | 92 ms | 12172 KB |
01-25.txt | AC | 157 ms | 21652 KB |
01-26.txt | AC | 281 ms | 25868 KB |
01-27.txt | AC | 280 ms | 26760 KB |
01-28.txt | AC | 187 ms | 16004 KB |
01-29.txt | AC | 82 ms | 8456 KB |
01-30.txt | AC | 189 ms | 16388 KB |
sample-01.txt | AC | 13 ms | 2044 KB |
sample-02.txt | AC | 13 ms | 2044 KB |