Contest Duration: ~ (local time) (100 minutes) Back to Home

Submission #1082681

Source Code Expand

Copy
```#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
v.resize(n);
for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int cnt[100010];

signed main() {
int n;
cin >> n;

vector<int> a;
inputVector(a, n);

sort(all(a));

vector<pair<int, int>> v;

int tmp = 1;
REP(i, 1, n - 1) {
if (a[i] == a[i - 1]) {
tmp++;
} else {
v.push_back(make_pair(a[i - 1], tmp));
tmp = 1;
}
}
v.push_back(make_pair(a[n - 1], tmp));

int num = 0;
bool over = false;
rep(i, v.size()) {
num += v[i].second - 1;
over |= v[i].second > 1;
}

int ret = n - max(over ? 2LL : 0LL, num);

cout << ret << endl;

return 0;
}
```

#### Submission Info

Submission Time 2017-01-28 21:35:43+0900 D - Card Eater iwashi31 C++14 (GCC 5.4.1) 0 1472 Byte WA 37 ms 3188 KB

#### Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 00_example_01.txt, 00_example_02.txt
All 0 / 400 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 2 ms 256 KB
00_example_02.txt 3 ms 256 KB
01.txt 3 ms 256 KB
02.txt 4 ms 256 KB
03.txt 3 ms 256 KB
04.txt 3 ms 256 KB
05.txt 3 ms 256 KB
06.txt 34 ms 1024 KB
07.txt 34 ms 1024 KB
08.txt 37 ms 1408 KB
09.txt 34 ms 1024 KB
10.txt 34 ms 1024 KB
11.txt 37 ms 1280 KB
12.txt 35 ms 1024 KB
13.txt 36 ms 1152 KB
14.txt 37 ms 3188 KB
15.txt 33 ms 1024 KB