Submission #6326402
Source Code Expand
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; int[10^^5] R; int[][10^^5] NS; void main() { auto nm = readln.split.to!(int[]); auto N = nm[0]; auto M = nm[1]; auto XS = readln.split.to!(int[]); if (M == 1) { writeln(N/2); return; } sort(XS); foreach (x; XS) { ++R[x%M]; NS[x%M] ~= x; } int ans = R[0]/2; foreach (i; 1..(M+1)/2) { auto d = min(R[i], R[M-i]); ans += d; R[i] -= d; R[M-i] -= d; } if (M%2 == 0) { auto d = R[M/2]/2; ans += d; R[M/2] -= d*2; } foreach (i; 1..10^^5) { int c; for (int j; j < NS[i].length; ++j) { if (NS[i].length > j+1 && NS[i][j] == NS[i][j+1]) { ++c; ++j; } } ans += min(c, R[i]/2); } writeln(ans); }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | cedretaber |
Language | D (DMD64 v2.070.1) |
Score | 700 |
Code Size | 975 Byte |
Status | AC |
Exec Time | 47 ms |
Memory | 7356 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 | 2 ms | 2176 KB |
01-02.txt | AC | 18 ms | 4988 KB |
01-03.txt | AC | 33 ms | 5820 KB |
01-04.txt | AC | 33 ms | 6204 KB |
01-05.txt | AC | 33 ms | 6460 KB |
01-06.txt | AC | 37 ms | 6076 KB |
01-07.txt | AC | 40 ms | 5948 KB |
01-08.txt | AC | 41 ms | 5948 KB |
01-09.txt | AC | 42 ms | 5948 KB |
01-10.txt | AC | 43 ms | 6844 KB |
01-11.txt | AC | 45 ms | 7228 KB |
01-12.txt | AC | 25 ms | 6192 KB |
01-13.txt | AC | 24 ms | 5424 KB |
01-14.txt | AC | 32 ms | 5948 KB |
01-15.txt | AC | 32 ms | 5948 KB |
01-16.txt | AC | 41 ms | 6460 KB |
01-17.txt | AC | 41 ms | 5820 KB |
01-18.txt | AC | 43 ms | 6844 KB |
01-19.txt | AC | 45 ms | 5948 KB |
01-20.txt | AC | 47 ms | 6716 KB |
01-21.txt | AC | 30 ms | 5820 KB |
01-22.txt | AC | 31 ms | 6076 KB |
01-23.txt | AC | 31 ms | 6460 KB |
01-24.txt | AC | 33 ms | 7100 KB |
01-25.txt | AC | 35 ms | 6204 KB |
01-26.txt | AC | 34 ms | 7356 KB |
01-27.txt | AC | 25 ms | 6240 KB |
01-28.txt | AC | 4 ms | 2428 KB |
01-29.txt | AC | 3 ms | 2300 KB |
01-30.txt | AC | 2 ms | 2176 KB |
sample-01.txt | AC | 2 ms | 2176 KB |
sample-02.txt | AC | 2 ms | 2176 KB |