Submission #994242
Source Code Expand
MAX_X = 10 ** 5 + 100 def main(): N, M = [int(i) for i in input().split()] X = [0] * (MAX_X + 1) for i in map(int, input().split()): X[i] += 1 Y = [sum(X[i::M]) for i in range(min(M, MAX_X))] # Mの倍数 ans = Y[0] // 2 Y[0] = 0 # M%2==0のM/2 if M % 2 == 0: ans += Y[M//2] // 2 Y[M//2] = 0 for i in range(1, M//2+1): j = M - i tmp = min(Y[i], Y[j]) ans += tmp Y[i] -= tmp Y[j] -= tmp try: for i, n in enumerate(X): j = i % M if Y[j] < 2 or n < 2: continue tmp = min(Y[j]-Y[j]%2, n-n%2) ans += tmp // 2 Y[j] -= tmp except IndexError: print(-1) print(ans) if __name__ == "__main__": main()
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | puyopop |
Language | PyPy3 (2.4.0) |
Score | 700 |
Code Size | 847 Byte |
Status | AC |
Exec Time | 323 ms |
Memory | 54380 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 229 ms | 40304 KB |
01-02.txt | AC | 275 ms | 51568 KB |
01-03.txt | AC | 272 ms | 51568 KB |
01-04.txt | AC | 290 ms | 51696 KB |
01-05.txt | AC | 282 ms | 51568 KB |
01-06.txt | AC | 289 ms | 51692 KB |
01-07.txt | AC | 287 ms | 51820 KB |
01-08.txt | AC | 303 ms | 51692 KB |
01-09.txt | AC | 306 ms | 51692 KB |
01-10.txt | AC | 315 ms | 52332 KB |
01-11.txt | AC | 323 ms | 54380 KB |
01-12.txt | AC | 281 ms | 51652 KB |
01-13.txt | AC | 298 ms | 52292 KB |
01-14.txt | AC | 280 ms | 51692 KB |
01-15.txt | AC | 280 ms | 51692 KB |
01-16.txt | AC | 284 ms | 51692 KB |
01-17.txt | AC | 290 ms | 51692 KB |
01-18.txt | AC | 300 ms | 51692 KB |
01-19.txt | AC | 301 ms | 51692 KB |
01-20.txt | AC | 316 ms | 53996 KB |
01-21.txt | AC | 280 ms | 51692 KB |
01-22.txt | AC | 282 ms | 51696 KB |
01-23.txt | AC | 285 ms | 51696 KB |
01-24.txt | AC | 302 ms | 51696 KB |
01-25.txt | AC | 304 ms | 51696 KB |
01-26.txt | AC | 316 ms | 53996 KB |
01-27.txt | AC | 286 ms | 47508 KB |
01-28.txt | AC | 264 ms | 45020 KB |
01-29.txt | AC | 251 ms | 42460 KB |
01-30.txt | AC | 262 ms | 44380 KB |
sample-01.txt | AC | 233 ms | 40176 KB |
sample-02.txt | AC | 233 ms | 39792 KB |