Submission #992437
Source Code Expand
#include <cstdio> #include <cstring> #include <cassert> #include <cmath> #include <vector> #include <list> #include <string> #include <set> #include <map> #include <queue> #include <stack> #include <algorithm> #include <iostream> #include <sstream> using namespace std; typedef long long i64; const int inf = (int)1.05e9; int main() { int n; int m; vector<int> xs; vector<int> count; vector<int> same; scanf("%d%d", &n, &m); xs.resize(n); count.resize(m); same.resize(m); for(int i = 0; i < n; ++i) { int x; scanf("%d", &x); xs[i] = x; } sort(xs.begin(), xs.end()); for(int i = 0; i < n; ++i) count[xs[i] % m] += 1; int lit = 0; while(lit < n) { int rit = lit + 1; while(xs[rit] == xs[lit] && rit < n) rit += 1; int c = (rit - lit) / 2; same[xs[lit] % m] += c; lit = rit; } int ans = 0; for(int i = 0; i <= (m - i); ++i) { int l = i; int r = (m - i); if(l == 0) { ans += count[l] / 2; continue; } else if(l == r) { ans += count[l] / 2; continue; } int pa = min(count[l], count[r]); int sa_l = min((count[l] - pa) / 2, same[l]); int sa_r = min((count[r] - pa) / 2, same[r]); //printf("%d: %d %d %d\n", i, pa, sa_l, sa_r); ans += (pa + sa_l + sa_r); } printf("%d\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | wafrelka |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1354 Byte |
Status | AC |
Exec Time | 21 ms |
Memory | 1408 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:29:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &n, &m); ^ ./Main.cpp:35:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] 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 | 3 ms | 256 KB |
01-02.txt | AC | 19 ms | 640 KB |
01-03.txt | AC | 20 ms | 640 KB |
01-04.txt | AC | 19 ms | 640 KB |
01-05.txt | AC | 19 ms | 640 KB |
01-06.txt | AC | 19 ms | 640 KB |
01-07.txt | AC | 19 ms | 768 KB |
01-08.txt | AC | 19 ms | 640 KB |
01-09.txt | AC | 19 ms | 640 KB |
01-10.txt | AC | 20 ms | 896 KB |
01-11.txt | AC | 21 ms | 1408 KB |
01-12.txt | AC | 14 ms | 640 KB |
01-13.txt | AC | 14 ms | 1024 KB |
01-14.txt | AC | 19 ms | 640 KB |
01-15.txt | AC | 19 ms | 640 KB |
01-16.txt | AC | 19 ms | 640 KB |
01-17.txt | AC | 19 ms | 640 KB |
01-18.txt | AC | 19 ms | 640 KB |
01-19.txt | AC | 19 ms | 768 KB |
01-20.txt | AC | 20 ms | 1408 KB |
01-21.txt | AC | 18 ms | 640 KB |
01-22.txt | AC | 18 ms | 640 KB |
01-23.txt | AC | 18 ms | 640 KB |
01-24.txt | AC | 18 ms | 640 KB |
01-25.txt | AC | 18 ms | 896 KB |
01-26.txt | AC | 19 ms | 1408 KB |
01-27.txt | AC | 12 ms | 1152 KB |
01-28.txt | AC | 4 ms | 1024 KB |
01-29.txt | AC | 3 ms | 512 KB |
01-30.txt | AC | 4 ms | 1024 KB |
sample-01.txt | AC | 3 ms | 256 KB |
sample-02.txt | AC | 3 ms | 256 KB |