Submission #993149
Source Code Expand
#include<bits/stdc++.h> using namespace std; int main() { long long int N, M; cin >> N >> M; vector<long long int> mod( M ), sub( M ); vector<long long int>data( 100001 ); for( size_t i = 0; i < N; i++ ) { long long int X; cin >> X; data[X]++; mod[X%M]++; } long long int ans = 0; ans += mod[0] / 2; if( M % 2 == 0 ) { ans += mod[M / 2] / 2; } //cout << ans << endl; for( size_t i = 1; i < (M + 1) / 2; i++ ) { //cout << min( mod[i], mod[M - i] ) << endl; ans += min( mod[i], mod[M - i] ); sub[i] = min( mod[i], mod[M - i] ); sub[M - i] = min( mod[i], mod[M - i] ); } for( size_t i = 0; i < 100001; i++ ) { if( i%M && (i%M) * 2 != M ) { if( data[i] % 2 == 1 && sub[i%M] > 0 ) { sub[i % M]--; data[i]--; } } } for( size_t i = 0; i < 100001; i++ ) { if( i%M && (i%M) * 2 != M ) { long long int xx = min( data[i], sub[i%M] * 2 ); data[i] -= xx; ans += data[i] / 2; if( data[i] / 2 ) { //cout << xx << " " << i << " " << data[i] << endl; } } } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | goryudyuma |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1089 Byte |
Status | WA |
Exec Time | 38 ms |
Memory | 2560 KB |
Judge Result
Set Name | sample | all | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 6 ms | 1024 KB |
01-02.txt | AC | 34 ms | 1024 KB |
01-03.txt | AC | 36 ms | 1024 KB |
01-04.txt | WA | 34 ms | 1024 KB |
01-05.txt | WA | 35 ms | 1024 KB |
01-06.txt | WA | 34 ms | 1024 KB |
01-07.txt | WA | 35 ms | 1024 KB |
01-08.txt | WA | 35 ms | 1024 KB |
01-09.txt | WA | 35 ms | 1024 KB |
01-10.txt | WA | 36 ms | 1664 KB |
01-11.txt | WA | 38 ms | 2560 KB |
01-12.txt | AC | 35 ms | 1024 KB |
01-13.txt | AC | 35 ms | 1664 KB |
01-14.txt | AC | 35 ms | 1024 KB |
01-15.txt | AC | 34 ms | 1024 KB |
01-16.txt | AC | 34 ms | 1024 KB |
01-17.txt | AC | 35 ms | 1024 KB |
01-18.txt | AC | 34 ms | 1024 KB |
01-19.txt | AC | 35 ms | 1152 KB |
01-20.txt | AC | 37 ms | 2560 KB |
01-21.txt | AC | 35 ms | 1024 KB |
01-22.txt | WA | 34 ms | 1024 KB |
01-23.txt | WA | 34 ms | 1024 KB |
01-24.txt | WA | 34 ms | 1024 KB |
01-25.txt | WA | 35 ms | 1536 KB |
01-26.txt | WA | 37 ms | 2560 KB |
01-27.txt | AC | 22 ms | 2560 KB |
01-28.txt | AC | 9 ms | 2560 KB |
01-29.txt | AC | 7 ms | 1664 KB |
01-30.txt | AC | 8 ms | 2560 KB |
sample-01.txt | AC | 6 ms | 1024 KB |
sample-02.txt | AC | 6 ms | 1024 KB |