Submission #1867974
Source Code Expand
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; #define INF 4001 int main(){ int n; cin >> n; vector<pair<int, int>> v; for(int i=0;i<n;i++){ int a; cin >> a; int flag=0; for(int i=0;i<v.size();i++){ if (v[i].second == a){ v[i].first++; flag=1; } } if (flag==0){ v.push_back(pair<int, int>(0, a)); } } //cout << "case1" << endl; sort(v.begin(), v.end()); int siz = v.size(); int ind=-1; for(int i=0;i<siz;i++){ if (v[i].first != 0){ ind=i; break; } } if(ind == -1){ cout << n << endl; return 0; }else if (ind == siz-1){ n -= v[siz-1].first * 2; cout << n << endl; return 0; } //cout << "case2" << endl; int ma=v[siz-1].first; for(int i=siz-2;i>=ind;i--){ if (ma == v[i].first){ n-=ma*2; if(i!=0){ i--; ma=v[i].first; }else{ ma=0; } }else if (ma > v[i].first){ n-=v[i].first*2; ma-=v[i].first; }else{ n-=ma*2; ma=v[i].first-ma; i--; } } //cout << "case3" << endl; if(ma>0){ n-=ma; } cout << n << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Card Eater |
User | misosoup |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1279 Byte |
Status | WA |
Exec Time | 2103 ms |
Memory | 1400 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt |
All | 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 1 ms | 256 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
01.txt | WA | 1 ms | 256 KB |
02.txt | WA | 3 ms | 256 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | WA | 1 ms | 256 KB |
05.txt | AC | 1 ms | 256 KB |
06.txt | WA | 37 ms | 256 KB |
07.txt | WA | 36 ms | 256 KB |
08.txt | WA | 584 ms | 512 KB |
09.txt | WA | 36 ms | 256 KB |
10.txt | WA | 34 ms | 256 KB |
11.txt | WA | 477 ms | 384 KB |
12.txt | WA | 39 ms | 256 KB |
13.txt | WA | 191 ms | 256 KB |
14.txt | TLE | 2103 ms | 1400 KB |
15.txt | WA | 29 ms | 256 KB |