Submission #1082175
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i = (a); i < int(b); ++i) #define rrep(i,b,a) for(int i = (b); i --> int(a);) #define trav(i,v) for(auto&i:v) #define all(c) (c).begin(), (c).end() #define sz(c) int((c).size()) #define vcr(v,n) vi v(n); trav(var,v) cin >> var; typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pii; int main(){ cin.tie(0); cin.sync_with_stdio(0); int n; cin >> n; int c[100100] = {}; deque<int> dq; rep(_,0,n){ int a; cin >> a; if(++c[a] == 2) dq.push_back(a); } sort(all(dq)); while(!dq.empty()){ int i = dq.front(); dq.pop_front(); while(c[i] > 1 && !dq.empty()){ int j = dq.front(); if(--c[j] == 1) dq.pop_front(); --c[i], n -= 2; } if(c[i] > 1) n -= 2*(c[i]-1); } cout << n << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Card Eater |
User | Herkar |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 835 Byte |
Status | WA |
Exec Time | 12 ms |
Memory | 640 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 | 3 ms | 640 KB |
00_example_02.txt | AC | 3 ms | 640 KB |
01.txt | AC | 3 ms | 640 KB |
02.txt | WA | 3 ms | 640 KB |
03.txt | AC | 3 ms | 640 KB |
04.txt | AC | 3 ms | 640 KB |
05.txt | AC | 3 ms | 640 KB |
06.txt | WA | 11 ms | 640 KB |
07.txt | WA | 11 ms | 640 KB |
08.txt | WA | 12 ms | 640 KB |
09.txt | WA | 11 ms | 640 KB |
10.txt | WA | 11 ms | 640 KB |
11.txt | WA | 11 ms | 640 KB |
12.txt | WA | 11 ms | 640 KB |
13.txt | WA | 11 ms | 640 KB |
14.txt | AC | 10 ms | 640 KB |
15.txt | WA | 10 ms | 640 KB |