Submission #6427823
Source Code Expand
#include <vector> #include <iostream> #include <cmath> #include <map> #include <unordered_map> #include <algorithm> #include <fstream> #include <unistd.h> #include <string> #include <numeric> #include <queue> #include <deque> #include <sstream> #include <iomanip> #include <set> #include <stack> #include <cassert> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<vvl> vvvl; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef vector<bool> vb; typedef vector<vector<bool>> vvb; typedef vector<vvb> vvvb; typedef vector<vvvb> vvvvb; typedef vector<string> vs; typedef vector<vs> vvs; typedef vector<vvs> vvvs; typedef vector<char> vc; typedef vector<vector<char>> vvc; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<vvd> vvvd; typedef pair<ll, ll> PL; typedef vector<PL> vpl; typedef vector<vector<PL>> vvpl; const int INF = 1001001001; const ll LINF = 1e17; const double pi = 3.1415926535897932; const string endstr = "\n"; #define FOR(i, a, b) for(ll i = (a); i < b; i++) #define RFOR(i, a, b) for(ll i = (a); i > b; i--) #define rep(i, n) for(ll i = 0; i < n; i++) #define rrep(i, n) for(ll i = n-1; i > -1; i--) #define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++) #define ff first #define ss second #define pb push_back #define epb emplace_back template <typename T> T gcd(T a, T b) { return (a == 0) ? b : gcd(b%a, a); } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;}; bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;}; bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;}; bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;}; template <typename T> vector<T> uniquen(vector<T> vec){ vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec; } inline ll popcnt(ll x){return __builtin_popcount((unsigned int)x);}; template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); ll N, M; cin >> N >> M; vvl m(M); rep(i, N){ ll x; cin >> x; m[x%M].pb(x); } ll ans = m[0].size()/2; FOR(i, 1, M/2+1){ auto& p1 = m[i]; auto& p2 = m[M-i]; if(p1.size() > p2.size()) swap(p1, p2); if(i == M/2 && M%2 == 0){ ans += p2.size()/2; } else { ans += p1.size(); ll cnt = 0; ll l = 0; while(l < p2.size()){ ll r = l; while(r < p2.size() && p2[r] == p2[l]) r++; ll c = r-l; cnt += c/2; l = r; } ans += min((ll)(p2.size()-p1.size())/2, cnt); } } cout << ans << endstr; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | k_k_hiroki |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 3165 Byte |
Status | WA |
Exec Time | 20 ms |
Memory | 5760 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, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 3 ms | 384 KB |
01-02.txt | AC | 11 ms | 1400 KB |
01-03.txt | AC | 10 ms | 1124 KB |
01-04.txt | WA | 11 ms | 1468 KB |
01-05.txt | WA | 10 ms | 1276 KB |
01-06.txt | WA | 11 ms | 1536 KB |
01-07.txt | WA | 10 ms | 1152 KB |
01-08.txt | WA | 11 ms | 1536 KB |
01-09.txt | WA | 13 ms | 1536 KB |
01-10.txt | WA | 18 ms | 2944 KB |
01-11.txt | AC | 20 ms | 4736 KB |
01-12.txt | AC | 11 ms | 1400 KB |
01-13.txt | AC | 11 ms | 2424 KB |
01-14.txt | AC | 11 ms | 1124 KB |
01-15.txt | AC | 11 ms | 1268 KB |
01-16.txt | AC | 11 ms | 1664 KB |
01-17.txt | AC | 11 ms | 1280 KB |
01-18.txt | AC | 14 ms | 2048 KB |
01-19.txt | AC | 16 ms | 1792 KB |
01-20.txt | AC | 19 ms | 5760 KB |
01-21.txt | AC | 11 ms | 1228 KB |
01-22.txt | WA | 10 ms | 1408 KB |
01-23.txt | WA | 11 ms | 1408 KB |
01-24.txt | WA | 12 ms | 1536 KB |
01-25.txt | WA | 15 ms | 2304 KB |
01-26.txt | AC | 16 ms | 3968 KB |
01-27.txt | AC | 10 ms | 4224 KB |
01-28.txt | AC | 3 ms | 2688 KB |
01-29.txt | AC | 2 ms | 1152 KB |
01-30.txt | AC | 3 ms | 2560 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |