Submission #5671961
Source Code Expand
from collections import defaultdict, Counter N, M = map(int, input().split()) x = list(map(int, input().split())) x.sort() c = Counter(x) a = defaultdict(int) E = defaultdict(int) for i,j in c.items(): a[i%M] += j E[i%M] += j//2 ans = a[0]//2 for i in range(1, M): j = M - i if i < j: m = min(a[i], a[j]) t = min((a[i] - m)//2, E[i]) + min((a[j] - m)//2, E[j]) ans += m+t elif i == j: #i==0は最初のifにかかってしまうため注意 ans += a[i] //2 print(ans)
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | siiiii1107 |
Language | PyPy3 (2.4.0) |
Score | 700 |
Code Size | 546 Byte |
Status | AC |
Exec Time | 306 ms |
Memory | 82152 KB |
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, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 165 ms | 38384 KB |
01-02.txt | AC | 237 ms | 55664 KB |
01-03.txt | AC | 238 ms | 55408 KB |
01-04.txt | AC | 238 ms | 55408 KB |
01-05.txt | AC | 231 ms | 55408 KB |
01-06.txt | AC | 232 ms | 55532 KB |
01-07.txt | AC | 232 ms | 55532 KB |
01-08.txt | AC | 234 ms | 55532 KB |
01-09.txt | AC | 255 ms | 56044 KB |
01-10.txt | AC | 302 ms | 67564 KB |
01-11.txt | AC | 306 ms | 79084 KB |
01-12.txt | AC | 205 ms | 52676 KB |
01-13.txt | AC | 252 ms | 60100 KB |
01-14.txt | AC | 234 ms | 61676 KB |
01-15.txt | AC | 235 ms | 61676 KB |
01-16.txt | AC | 237 ms | 61676 KB |
01-17.txt | AC | 235 ms | 61804 KB |
01-18.txt | AC | 254 ms | 61548 KB |
01-19.txt | AC | 270 ms | 62184 KB |
01-20.txt | AC | 271 ms | 82152 KB |
01-21.txt | AC | 226 ms | 52332 KB |
01-22.txt | AC | 223 ms | 52336 KB |
01-23.txt | AC | 226 ms | 52336 KB |
01-24.txt | AC | 235 ms | 52464 KB |
01-25.txt | AC | 283 ms | 61680 KB |
01-26.txt | AC | 288 ms | 73452 KB |
01-27.txt | AC | 245 ms | 70676 KB |
01-28.txt | AC | 229 ms | 62828 KB |
01-29.txt | AC | 220 ms | 49516 KB |
01-30.txt | AC | 204 ms | 60012 KB |
sample-01.txt | AC | 168 ms | 38256 KB |
sample-02.txt | AC | 169 ms | 38256 KB |