Submission #993045
Source Code Expand
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x; x = x * x; n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
#define For(i,a,b) for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n) For(i,0,n)
#define rFor(i,a,b) for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n) rFor(i,n,0)
#define each(i,n) for(auto &i : n)
#define clr(a) memset((a), 0 ,sizeof(a))
#define mclr(a) memset((a), -1 ,sizeof(a))
#define all(a) (a).begin(),(a).end()
#define sz(a) (sizeof(a))
#define tostr(a) tostring(a)
#define dump(val) cerr << #val " = " << val << endl;
#define Fill(a,v) fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)
const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };
const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;
#define int ll
#define double ld
signed main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
int n, m;
cin >> n >> m;
map<int, int> mp;
map<int, int> mp2;
rep(i, n) {
int x;
cin >> x;
mp2[x]++;
}
each(i, mp2) {
if (i.second % 2) {
mp[i.first % m]++;
i.second--;
}
}
int ans = 0;
each(i, mp) {
int x = i.first;
int tm = min(mp[m - x], i.second);
if (x == m - x) {
tm /= 2;
i.second -= tm * 2;
ans += tm;
continue;
}
i.second -= tm;
mp[m - x] -= tm;
ans += tm;
}
ans += mp[0] / 2;
each(i, mp2) {
int t = min(i.second, mp[m - i.first % m]);
i.second -= t;
ans += t;
ans += i.second / 2;
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
D - Pair Cards |
User |
omu |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2587 Byte |
Status |
WA |
Exec Time |
125 ms |
Memory |
12800 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 |
2 ms |
256 KB |
01-02.txt |
AC |
44 ms |
4224 KB |
01-03.txt |
AC |
44 ms |
4224 KB |
01-04.txt |
WA |
45 ms |
4224 KB |
01-05.txt |
WA |
45 ms |
4224 KB |
01-06.txt |
WA |
47 ms |
4224 KB |
01-07.txt |
WA |
47 ms |
4224 KB |
01-08.txt |
WA |
50 ms |
4224 KB |
01-09.txt |
WA |
51 ms |
4352 KB |
01-10.txt |
WA |
66 ms |
6656 KB |
01-11.txt |
AC |
82 ms |
9216 KB |
01-12.txt |
AC |
11 ms |
256 KB |
01-13.txt |
AC |
11 ms |
256 KB |
01-14.txt |
AC |
54 ms |
6528 KB |
01-15.txt |
AC |
54 ms |
6528 KB |
01-16.txt |
AC |
60 ms |
6528 KB |
01-17.txt |
AC |
65 ms |
6528 KB |
01-18.txt |
AC |
66 ms |
6656 KB |
01-19.txt |
AC |
72 ms |
7296 KB |
01-20.txt |
AC |
125 ms |
12800 KB |
01-21.txt |
AC |
20 ms |
512 KB |
01-22.txt |
WA |
20 ms |
512 KB |
01-23.txt |
WA |
21 ms |
512 KB |
01-24.txt |
WA |
21 ms |
640 KB |
01-25.txt |
AC |
22 ms |
896 KB |
01-26.txt |
AC |
22 ms |
896 KB |
01-27.txt |
AC |
78 ms |
9600 KB |
01-28.txt |
AC |
6 ms |
896 KB |
01-29.txt |
AC |
3 ms |
384 KB |
01-30.txt |
AC |
3 ms |
256 KB |
sample-01.txt |
AC |
2 ms |
256 KB |
sample-02.txt |
AC |
3 ms |
256 KB |