CODE FESTIVAL 2016 Final

Submission #5891926

Source codeソースコード

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll linf = 1e18;
const int inf = 1e9;
long long dx[4] = {1, 0, -1, 0};
long long dy[4] = {0, 1, 0, -1};
ll pause;

#define vl vector<ll>
#define pg priority_queue<ll, vector<ll>, greater<ll>>
#define pq priority_queue<ll>
#define np(x) next_permutation(x.begin(), x.end())
#define rp(i, n) for (long long i = 0; i < n; i++)
#define pr(i, n) for (long long i = n - 1; i >= 0; i--)
#define fm(i, mp) for (auto i = (mp).begin(); i != (mp).end(); ++i)
#define ac(v) accumulate(v.begin(), v.end(), 0);
#define al(v) (v).begin(), (v).end()
#define mz(x) memset(x, 0, sizeof(x))
#define mi(x) memset(x, 0x3F, sizeof(x))
#define ce(x) cout << (x) << endl
#define cs(x) cout << (x) << ' '
#define co(x) cout << (x)
#define cd(x, y) cout << setprecision(x) << (y) << endl
#define ma make_pair
#define pb push_back
#define fs first
#define sc second
#define ceo cout << endl
#define cso cout << ' '
#define gr(i, j, k, w, h) if (i + dx[k] >= 0 && i + dx[k] < h && j + dy[k] >= 0 && j + dy[k] < w)
clock_t startT, endT;
long long time()
{
    endT = clock();
    cerr << (endT - startT) / 1000 << "ms" << endl;
    cerr << endl;
    return (endT - startT) / 1000;
}

int main()
{
    startT = clock();
    cin.tie(0);
    ios::sync_with_stdio(0);
    //=========================================================
    ll n, m;
    cin >> n >> m;

    ll x[n];
    rp(i, n) cin >> x[i];

    ll count[m + 1];
    ll same[111111];
    mz(same);
    mz(count);

    rp(i, n)
    {
        count[x[i] % m]++;
        same[x[i]]++;
    }
    ll ans = 0;

    ll co = ll(m / 2) + 1;
    rp(i, co)
    {
        if (i != (m - i) % m)
        {
            ans += min(count[i], count[m - i]);
            ll mi = min(count[i], count[m - i]);
            count[i] -= mi;
            count[m - i] -= mi;
        }
        else
        {
            ans += count[i] / 2;
            count[i] = count[i] % 2;
        }
    }

    rp(i, 11111)
    {
        if (ll(same[i] / 2) > 0)
        {
            ans += min((same[i] / 2), (count[i % m] / 2));

            count[i % m] -= min((same[i] - same[i] % 2), (count[i % m] - count[i % m] % 2));
        }
    }

    ce(ans);
    //=========================================================
    time();
    return 0;
}
// 1 5 6 0 11 11 11 10 21 15 15 16 9 9 9

Submission

Task問題 D - Pair Cards
User nameユーザ名 Sanou
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 2453 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt
all 0 / 700 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 2 ms 1152 KB
01-02.txt AC 10 ms 1920 KB
01-03.txt AC 10 ms 1920 KB
01-04.txt AC 10 ms 1920 KB
01-05.txt AC 10 ms 1920 KB
01-06.txt AC 10 ms 1920 KB
01-07.txt AC 10 ms 1920 KB
01-08.txt WA
01-09.txt WA
01-10.txt WA
01-11.txt WA
01-12.txt WA
01-13.txt WA
01-14.txt AC 10 ms 1920 KB
01-15.txt AC 10 ms 1920 KB
01-16.txt AC 10 ms 1920 KB
01-17.txt AC 10 ms 1920 KB
01-18.txt AC 10 ms 1920 KB
01-19.txt AC 10 ms 2048 KB
01-20.txt AC 11 ms 2688 KB
01-21.txt AC 10 ms 1920 KB
01-22.txt AC 10 ms 1920 KB
01-23.txt WA
01-24.txt WA
01-25.txt WA
01-26.txt WA
01-27.txt AC 7 ms 2304 KB
01-28.txt WA
01-29.txt AC 2 ms 1408 KB
01-30.txt AC 2 ms 1920 KB
sample-01.txt AC 2 ms 1152 KB
sample-02.txt AC 2 ms 1152 KB