Submission #11351213


Source Code Expand

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

public class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = in.nextInt();
        int m = in.nextInt();
        int[] count = new int[m];
        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
            count[x % m]++;
        }
        long ans = 0;
        for (int i = 0; i <= m / 2; i++) {
            if (i * 2 == m || i == 0) {
                ans += count[i] / 2;
            } else {
                ans += (count[i] + count[m - i]) / 2;
            }
        }
        out.println(ans);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private PrintWriter out = new PrintWriter(System.out);
    boolean autoFlush = false;

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(int[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : a) {
            joiner.add(Integer.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(long[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (long i : a) {
            joiner.add(Long.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void flush() {
        out.flush();
    }
}

Submission Info

Submission Time
Task D - Pair Cards
User Yu_212
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 3614 Byte
Status WA
Exec Time 167 ms
Memory 35092 KB

Judge Result

Set Name sample all
Score / Max Score 0 / 0 0 / 700
Status
AC × 1
WA × 1
AC × 28
WA × 6
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 71 ms 19540 KB
01-02.txt AC 153 ms 33304 KB
01-03.txt AC 161 ms 31672 KB
01-04.txt AC 166 ms 30784 KB
01-05.txt AC 167 ms 32896 KB
01-06.txt AC 157 ms 31408 KB
01-07.txt AC 159 ms 33752 KB
01-08.txt AC 153 ms 30356 KB
01-09.txt AC 161 ms 30052 KB
01-10.txt WA 162 ms 31276 KB
01-11.txt AC 155 ms 32496 KB
01-12.txt AC 166 ms 32884 KB
01-13.txt AC 159 ms 33756 KB
01-14.txt AC 161 ms 31188 KB
01-15.txt AC 153 ms 30616 KB
01-16.txt AC 154 ms 31852 KB
01-17.txt AC 160 ms 33764 KB
01-18.txt AC 153 ms 32960 KB
01-19.txt AC 160 ms 33636 KB
01-20.txt AC 152 ms 31704 KB
01-21.txt AC 155 ms 35092 KB
01-22.txt AC 160 ms 30692 KB
01-23.txt AC 161 ms 33460 KB
01-24.txt WA 162 ms 31124 KB
01-25.txt WA 153 ms 33364 KB
01-26.txt AC 151 ms 31204 KB
01-27.txt AC 136 ms 29644 KB
01-28.txt AC 84 ms 17876 KB
01-29.txt WA 75 ms 25044 KB
01-30.txt AC 73 ms 20692 KB
sample-01.txt AC 71 ms 20564 KB
sample-02.txt WA 70 ms 20180 KB