Submission #2424118
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; vector< ll > x(n); for(ll i = 0; i < n; i++)cin >> x[i]; sort(x.begin(),x.end()); ll mod[m],same[m]; memset(mod,0,sizeof(mod)); memset(same,0,sizeof(same)); for(ll i = 0; i < n; i++) { ll a = x[i]%m; mod[a]++; if(i>0) { if(x[i]==x[i-1]) { same[a]++; } } } 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; if(mod[i]==mod[j]) { ans += mod[i]; } else if(mod[i]>mod[j]) { ans += mod[j]; ll left = mod[i] - mod[j]; left = min(left,same[i]); ans += left/2; } else { ans += mod[i]; ll left = mod[j] - mod[i]; left = min(left,same[j]); ans += left/2; } } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | amostanls |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1905 Byte |
Status | WA |
Exec Time | 18 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, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 1 ms | 256 KB |
01-02.txt | AC | 17 ms | 1024 KB |
01-03.txt | AC | 17 ms | 1024 KB |
01-04.txt | AC | 17 ms | 1024 KB |
01-05.txt | AC | 17 ms | 1024 KB |
01-06.txt | AC | 17 ms | 1024 KB |
01-07.txt | AC | 17 ms | 1024 KB |
01-08.txt | AC | 17 ms | 1024 KB |
01-09.txt | WA | 17 ms | 1024 KB |
01-10.txt | WA | 17 ms | 1664 KB |
01-11.txt | WA | 18 ms | 2560 KB |
01-12.txt | AC | 11 ms | 1024 KB |
01-13.txt | WA | 12 ms | 1792 KB |
01-14.txt | AC | 16 ms | 1024 KB |
01-15.txt | AC | 16 ms | 1024 KB |
01-16.txt | AC | 16 ms | 1024 KB |
01-17.txt | AC | 16 ms | 1024 KB |
01-18.txt | AC | 16 ms | 1152 KB |
01-19.txt | AC | 17 ms | 1280 KB |
01-20.txt | AC | 17 ms | 2560 KB |
01-21.txt | AC | 16 ms | 1024 KB |
01-22.txt | AC | 16 ms | 1024 KB |
01-23.txt | AC | 16 ms | 1024 KB |
01-24.txt | WA | 15 ms | 1024 KB |
01-25.txt | WA | 16 ms | 1536 KB |
01-26.txt | WA | 16 ms | 2560 KB |
01-27.txt | AC | 10 ms | 2176 KB |
01-28.txt | WA | 2 ms | 1792 KB |
01-29.txt | AC | 2 ms | 896 KB |
01-30.txt | AC | 2 ms | 1792 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |