Submission #992254
Source Code Expand
#include <iostream> #include <fstream> #include <sstream> #include <vector> #include <set> #include <bitset> #include <map> #include <deque> #include <string> #include <algorithm> #include <numeric> #include <cstdio> #include <cassert> #include <cstdlib> #include <cstring> #include <ctime> #include <cmath> #define pb push_back #define pbk pop_back #define mp make_pair #define fs first #define sc second #define all(x) (x).begin(), (x).end() #define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i) #define len(a) ((int) (a).size()) #ifdef CUTEBMAING #define eprintf(...) fprintf(stderr, __VA_ARGS__) #else #define eprintf(...) 42 #endif using namespace std; typedef long long int64; typedef long double ld; typedef unsigned long long lint; const int inf = (1 << 30) - 1; const int64 linf = (1ll << 62) - 1; const int N = 1e6 + 100; vector<int> a[N]; inline int match(vector<int> a, vector<int> b) { if (len(a) < len(b)) { swap(a, b); } int can = len(b); int left = (len(a) - len(b)) / 2; map<int, int> c; for (int i : a) { c[i]++; } for (auto i : c) { int cnt = min(left, i.sc / 2); left -= cnt; can += cnt; } return can; } int main() { #ifdef XCODE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { int x; scanf("%d", &x); a[x % m].pb(x); } for (int i = 0; i < m; i++) { sort(all(a[i])); } int ans = 0; for (int i = 0; i < m && i <= m - i; i++) { if ((2 * i) % m == 0 || i == 0) { ans += len(a[i]) / 2; } else { ans += match(a[i], a[m - i]); } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | darinflar |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1896 Byte |
Status | AC |
Exec Time | 55 ms |
Memory | 26752 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:74:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] int x; scanf("%d", &x); ^
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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 27 ms | 23680 KB |
01-02.txt | AC | 44 ms | 24316 KB |
01-03.txt | AC | 44 ms | 24316 KB |
01-04.txt | AC | 49 ms | 25464 KB |
01-05.txt | AC | 47 ms | 25088 KB |
01-06.txt | AC | 47 ms | 24576 KB |
01-07.txt | AC | 45 ms | 24192 KB |
01-08.txt | AC | 44 ms | 24320 KB |
01-09.txt | AC | 45 ms | 24320 KB |
01-10.txt | AC | 51 ms | 24960 KB |
01-11.txt | AC | 55 ms | 25728 KB |
01-12.txt | AC | 40 ms | 24568 KB |
01-13.txt | AC | 40 ms | 24568 KB |
01-14.txt | AC | 44 ms | 24212 KB |
01-15.txt | AC | 51 ms | 25216 KB |
01-16.txt | AC | 47 ms | 24448 KB |
01-17.txt | AC | 45 ms | 24320 KB |
01-18.txt | AC | 46 ms | 24576 KB |
01-19.txt | AC | 47 ms | 24448 KB |
01-20.txt | AC | 55 ms | 26752 KB |
01-21.txt | AC | 43 ms | 24256 KB |
01-22.txt | AC | 43 ms | 24192 KB |
01-23.txt | AC | 42 ms | 24320 KB |
01-24.txt | AC | 41 ms | 24320 KB |
01-25.txt | AC | 43 ms | 24448 KB |
01-26.txt | AC | 44 ms | 24448 KB |
01-27.txt | AC | 42 ms | 25216 KB |
01-28.txt | AC | 29 ms | 23808 KB |
01-29.txt | AC | 28 ms | 23680 KB |
01-30.txt | AC | 28 ms | 23680 KB |
sample-01.txt | AC | 27 ms | 23680 KB |
sample-02.txt | AC | 27 ms | 23808 KB |