Submission #2424149
Source Code Expand
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define fi first #define se second #define mp make_pair #define pb push_back #define fbo find_by_order #define ook order_of_key typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; typedef pair <ll, int> pli; typedef vector<int> vi; typedef vector<ll> vl; typedef long double ld; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; typedef set<int>::iterator sit; typedef map<int,int>::iterator mit; typedef vector<int>::iterator vit; long long INF=numeric_limits<long long>::max(); int main() { ios_base::sync_with_stdio(0); cin.tie(0); //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); ll n,m,ans(0); cin >> n >> m; ll mod[m],same[100001],smod[m]; memset(mod,0,sizeof(mod)); memset(smod,0,sizeof(smod)); memset(same,0,sizeof(same)); vector< ll > x(n); for(ll i = 0; i < n; i++) { cin >> x[i]; same[x[i]]++; } for(ll i = 1; i <= 100000; i++) { ll a = i%m; mod[a]+=same[i]; smod[a]+=same[i]/2; } ans += mod[0]/2; if(m%2==0)ans += mod[m/2]/2; for(ll i = 1; i < (m+1)/2; i++) { ll j = m-i; //cout << mod[i] << " " << mod[j] << endl; if(mod[i]==mod[j]) { ans += mod[i]; } else if(mod[i]>mod[j]) { ans += mod[j]; ll left = mod[i] - mod[j]; //cout << left/2 << " " << smod[i] << endl; left = min(left/2,smod[i]); ans += left; } else { ans += mod[i]; ll left = mod[j] - mod[i]; left = min(left/2,smod[j]); ans += left; } } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | vjudge2 |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1913 Byte |
Status | AC |
Exec Time | 12 ms |
Memory | 3328 KB |
Judge Result
Set Name | sample | all | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 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 | 1024 KB |
01-02.txt | AC | 11 ms | 1792 KB |
01-03.txt | AC | 11 ms | 1792 KB |
01-04.txt | AC | 11 ms | 1792 KB |
01-05.txt | AC | 11 ms | 1792 KB |
01-06.txt | AC | 11 ms | 1792 KB |
01-07.txt | AC | 11 ms | 1792 KB |
01-08.txt | AC | 11 ms | 1792 KB |
01-09.txt | AC | 11 ms | 1920 KB |
01-10.txt | AC | 11 ms | 2432 KB |
01-11.txt | AC | 12 ms | 3328 KB |
01-12.txt | AC | 10 ms | 1792 KB |
01-13.txt | AC | 11 ms | 2560 KB |
01-14.txt | AC | 11 ms | 1792 KB |
01-15.txt | AC | 11 ms | 1792 KB |
01-16.txt | AC | 11 ms | 1792 KB |
01-17.txt | AC | 11 ms | 1792 KB |
01-18.txt | AC | 11 ms | 1920 KB |
01-19.txt | AC | 11 ms | 2048 KB |
01-20.txt | AC | 11 ms | 3328 KB |
01-21.txt | AC | 10 ms | 1792 KB |
01-22.txt | AC | 10 ms | 1792 KB |
01-23.txt | AC | 11 ms | 1792 KB |
01-24.txt | AC | 11 ms | 1792 KB |
01-25.txt | AC | 11 ms | 2304 KB |
01-26.txt | AC | 11 ms | 3328 KB |
01-27.txt | AC | 7 ms | 2944 KB |
01-28.txt | AC | 4 ms | 2688 KB |
01-29.txt | AC | 3 ms | 1664 KB |
01-30.txt | AC | 3 ms | 2560 KB |
sample-01.txt | AC | 3 ms | 1024 KB |
sample-02.txt | AC | 3 ms | 1024 KB |