Submission #7928444


Source Code Expand

Copy
/*
*
*   解説見てないお
*
*/
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int main() {
    int n, m; cin >> n >> m;
    vector<int> x(n),y(m,0),z(100001,0);
    REP(i, n) {
        scanf("%d", &x[i]);
        y[x[i] % m]++;
        z[x[i]]++;
    }
    ll ans = 0;
    REP(i, m/2 + 1) {
        if (i == m - i || i == 0) {
            ans += y[i] / 2;
            y[i] %= 2;
        }
        else {
            int a = min(y[i], y[m - i]);
            ans += a;
            y[i] -= a;
            y[m - i] -= a;
        }
    }
    REP(i, 100001) {
        if (z[i] > 1 && y[i % m]) {
            int a = min(z[i] / 2, y[i % m] / 2);
            y[i % m] -= a * 2;
            ans += a;
        }
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task D - Pair Cards
User kanpurin
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1002 Byte
Status
Exec Time 13 ms
Memory 1408 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:19:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x[i]);
                           ^

Judge Result

Set Name sample all
Score / Max Score 0 / 0 700 / 700
Status
Test Cases sample-01.txt, sample-02.txt 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
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 1 ms 640 KB
01-02.txt 11 ms 1024 KB
01-03.txt 11 ms 1024 KB
01-04.txt 11 ms 1024 KB
01-05.txt 11 ms 1024 KB
01-06.txt 11 ms 1024 KB
01-07.txt 12 ms 1024 KB
01-08.txt 12 ms 1024 KB
01-09.txt 12 ms 1024 KB
01-10.txt 12 ms 1152 KB
01-11.txt 13 ms 1408 KB
01-12.txt 11 ms 1024 KB
01-13.txt 11 ms 1152 KB
01-14.txt 11 ms 1024 KB
01-15.txt 11 ms 1024 KB
01-16.txt 11 ms 1024 KB
01-17.txt 11 ms 1024 KB
01-18.txt 11 ms 1024 KB
01-19.txt 11 ms 1024 KB
01-20.txt 12 ms 1408 KB
01-21.txt 11 ms 1024 KB
01-22.txt 11 ms 1024 KB
01-23.txt 11 ms 1024 KB
01-24.txt 11 ms 1024 KB
01-25.txt 11 ms 1152 KB
01-26.txt 12 ms 1408 KB
01-27.txt 7 ms 1280 KB
01-28.txt 2 ms 1024 KB
01-29.txt 2 ms 768 KB
01-30.txt 2 ms 1024 KB
sample-01.txt 2 ms 640 KB
sample-02.txt 2 ms 640 KB