Submission #7652849
Source Code Expand
#include <algorithm> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) //#define cerr if(false) cerr #ifdef DEBUG #define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__); #else #define show(...) 42 #endif using namespace std; using ll = long long; using pii = pair<int, int>; template <typename T, typename S> ostream& operator<<(ostream& os, pair<T, S> a) { os << '(' << a.first << ',' << a.second << ')'; return os; } template <typename T> ostream& operator<<(ostream& os, vector<T> v) { for (auto x : v) os << x << ' '; return os; } void debug() { cerr << '\n'; } template <typename H, typename... T> void debug(H a, T... b) { cerr << a; if (sizeof...(b)) cerr << ", "; debug(b...); } #ifdef DEBUG template<typename T> class Vec : public vector<T>{ public: Vec(){} Vec(int n):vector<T>(n){} Vec(int n, T a):vector<T>(n,a){} T& operator[](long long n){ if(n < 0 or n >= this->size())throw out_of_range("Vec"); return this->at(n); } const T& operator[](long long n)const{ if(n < 0 or n >= this->size())throw out_of_range("Vec"); return this->at(n); } }; #define vector Vec template<typename T> ostream &operator<<(ostream &os, set<T> st) { for(auto x : st) cerr << x << ' '; return os; } template<typename T, typename S> ostream &operator<<(ostream &os, map<T, S> mp) { for(auto x : mp) cerr << x << ' '; return os; } #endif int main(){ cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; vector<int>a(n); vector<vector<int>>b(m); rep(i,n){ cin >> a[i]; b[a[i]%m].push_back(a[i]); } rep(i,m)sort(b[i].begin(), b[i].end()); int ans = 0; for(int i = 1; i < m / 2; i++){ int s = (int) min(b[i].size(), b[m-i].size()); ans += s; if(b[i].size() < b[m-i].size())swap(b[i], b[m-i]); int t =(int) b[i].size(); for(int j = 0; j < (int)b[i].size() - 1; j++){ show(b[i].size()); if(b[i][j] == b[i][j+1]){ if(t - 2 >= s){ ans++; j++; t-=2; } } } show(ans); } if(m % 2 == 0){ ans += b[m / 2].size() / 2; }else{ int i = m / 2; int s = (int) min(b[i].size(), b[m-i].size()); ans += s; if(b[i].size() < b[m-i].size())swap(b[i], b[m-i]); int t =(int) b[i].size(); for(int j = 0; j < (int)b[i].size() - 1; j++){ if(b[i][j] == b[i][j+1]){ if(t - 2 >= s){ ans++; j++; t-=2; } } } } ans += b[0].size() / 2; cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | polyomino |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 3283 Byte |
Status | RE |
Exec Time | 116 ms |
Memory | 6144 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 | RE | 103 ms | 256 KB |
01-02.txt | RE | 116 ms | 1276 KB |
01-03.txt | AC | 16 ms | 1276 KB |
01-04.txt | AC | 16 ms | 1280 KB |
01-05.txt | AC | 16 ms | 1152 KB |
01-06.txt | AC | 15 ms | 1408 KB |
01-07.txt | AC | 15 ms | 1152 KB |
01-08.txt | AC | 14 ms | 1280 KB |
01-09.txt | AC | 14 ms | 1280 KB |
01-10.txt | AC | 19 ms | 2816 KB |
01-11.txt | AC | 21 ms | 4992 KB |
01-12.txt | AC | 12 ms | 1276 KB |
01-13.txt | AC | 12 ms | 2300 KB |
01-14.txt | AC | 16 ms | 1172 KB |
01-15.txt | AC | 16 ms | 1280 KB |
01-16.txt | AC | 15 ms | 1408 KB |
01-17.txt | AC | 14 ms | 1152 KB |
01-18.txt | AC | 15 ms | 1536 KB |
01-19.txt | AC | 17 ms | 1664 KB |
01-20.txt | AC | 20 ms | 6144 KB |
01-21.txt | AC | 15 ms | 1280 KB |
01-22.txt | AC | 15 ms | 1152 KB |
01-23.txt | AC | 14 ms | 1280 KB |
01-24.txt | AC | 13 ms | 1280 KB |
01-25.txt | AC | 15 ms | 2176 KB |
01-26.txt | AC | 16 ms | 3712 KB |
01-27.txt | AC | 11 ms | 4352 KB |
01-28.txt | AC | 4 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 |