Submission #7853926
Source Code Expand
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Linq; using static MyIO; public class D { public static void Main() => (new Solver()).Solve(); } public class Solver { public void Solve() { int MAX = 100000; int N = GetInt(); int M = GetInt(); int[] X = GetInts(N); int[] grpcnt = new int[M]; int[] cnt = new int[MAX + 1]; for(int i = 0; i < N; i++) { grpcnt[X[i] % M]++; cnt[X[i]]++; } int ans = grpcnt[0] / 2; if(M % 2 == 0) ans += grpcnt[M/2] / 2; for(int i = 1; i < (M + 1)/2; i++) { int a = i; int b = M - i; if(grpcnt[a] < grpcnt[b]) swap(ref a, ref b); ans += grpcnt[b]; int rest = grpcnt[a] - grpcnt[b]; for(int j = a; j <= MAX; j += M) { int diff = Math.Min(rest, cnt[j]) / 2; ans += diff; rest -= diff * 2; if(rest < 2) break; } } Console.WriteLine(ans); } private void swap(ref int x, ref int y) { int tmp = x; x = y; y = tmp; } } public static class MyIO { private static string[] args = null; private static int num = -1; private static int used = -1; private static string getArg() { if(used == num) { args = Console.ReadLine().Split(' '); num = args.Length; used = 0; } return args[used++]; } public static int GetInt() => int.Parse(getArg()); public static long GetLong() => long.Parse(getArg()); public static double GetDouble() => double.Parse(getArg()); public static string GetString() => getArg(); public static char GetChar() => getArg()[0]; public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray(); public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray(); public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray(); public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray(); }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | DM7PvTyc |
Language | C# (Mono 4.6.2.0) |
Score | 700 |
Code Size | 2062 Byte |
Status | AC |
Exec Time | 69 ms |
Memory | 23648 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 | 24 ms | 9440 KB |
01-02.txt | AC | 65 ms | 19552 KB |
01-03.txt | AC | 66 ms | 21600 KB |
01-04.txt | AC | 69 ms | 21600 KB |
01-05.txt | AC | 67 ms | 23648 KB |
01-06.txt | AC | 66 ms | 21600 KB |
01-07.txt | AC | 67 ms | 23520 KB |
01-08.txt | AC | 65 ms | 19552 KB |
01-09.txt | AC | 67 ms | 21600 KB |
01-10.txt | AC | 67 ms | 21728 KB |
01-11.txt | AC | 66 ms | 19936 KB |
01-12.txt | AC | 65 ms | 21600 KB |
01-13.txt | AC | 66 ms | 21856 KB |
01-14.txt | AC | 67 ms | 21600 KB |
01-15.txt | AC | 66 ms | 19552 KB |
01-16.txt | AC | 66 ms | 23648 KB |
01-17.txt | AC | 65 ms | 19552 KB |
01-18.txt | AC | 66 ms | 21600 KB |
01-19.txt | AC | 65 ms | 19680 KB |
01-20.txt | AC | 67 ms | 19936 KB |
01-21.txt | AC | 66 ms | 23520 KB |
01-22.txt | AC | 66 ms | 19552 KB |
01-23.txt | AC | 65 ms | 19552 KB |
01-24.txt | AC | 66 ms | 19552 KB |
01-25.txt | AC | 66 ms | 21728 KB |
01-26.txt | AC | 66 ms | 21984 KB |
01-27.txt | AC | 45 ms | 15968 KB |
01-28.txt | AC | 26 ms | 12372 KB |
01-29.txt | AC | 25 ms | 11616 KB |
01-30.txt | AC | 25 ms | 11872 KB |
sample-01.txt | AC | 25 ms | 13536 KB |
sample-02.txt | AC | 25 ms | 13536 KB |