CODE FESTIVAL 2016 Final

Submission #1318751

Source codeソースコード

#include <bits/stdc++.h>
using namespace std;

const int DIM = 1e5 + 5;

int cnt1[DIM], frq[DIM], cnt2[DIM];

int main( void ) {
    
    int n, m;
    cin >> n >> m;
    
    for( int i = 1; i <= n; i ++ ) {
        int x;
        cin >> x;
        
        cnt1[x % m] ++;
        
        frq[x] ++;
        if( frq[x] % 2 == 0 )
            cnt2[x % m] ++;
    }
    
    int ans = cnt1[0] / 2;
    cnt1[0] = 0;
   
    if( m % 2 == 0 ) {
        ans += cnt1[m / 2] / 2;
        cnt1[m / 2] = 0;
    }
    
    for( int i = 1; i <= m / 2; i ++ ) {
        int aux = min( cnt1[i], cnt1[m - i] );
        
        ans += aux;
        cnt1[i] -= aux;
        cnt1[m - i] -= aux;
    }
    
    for( int i = 1; i < m; i ++ )
        ans += min( cnt1[i] / 2, cnt2[i] );
    
    cout << ans << endl;
    return 0;
}

Submission

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

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt
all 700 / 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 1 ms 256 KB
01-02.txt AC 37 ms 640 KB
01-03.txt AC 36 ms 640 KB
01-04.txt AC 38 ms 640 KB
01-05.txt AC 37 ms 640 KB
01-06.txt AC 36 ms 640 KB
01-07.txt AC 36 ms 640 KB
01-08.txt AC 37 ms 640 KB
01-09.txt AC 37 ms 640 KB
01-10.txt AC 37 ms 896 KB
01-11.txt AC 37 ms 1408 KB
01-12.txt AC 37 ms 256 KB
01-13.txt AC 38 ms 384 KB
01-14.txt AC 36 ms 640 KB
01-15.txt AC 36 ms 640 KB
01-16.txt AC 36 ms 640 KB
01-17.txt AC 36 ms 640 KB
01-18.txt AC 36 ms 640 KB
01-19.txt AC 35 ms 640 KB
01-20.txt AC 38 ms 1024 KB
01-21.txt AC 37 ms 640 KB
01-22.txt AC 37 ms 640 KB
01-23.txt AC 38 ms 640 KB
01-24.txt AC 37 ms 640 KB
01-25.txt AC 38 ms 896 KB
01-26.txt AC 38 ms 1408 KB
01-27.txt AC 19 ms 896 KB
01-28.txt AC 3 ms 1152 KB
01-29.txt AC 2 ms 768 KB
01-30.txt AC 2 ms 640 KB
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 1 ms 256 KB