Official
B - Who is missing? Editorial by en_translator
There exists a unique integer \(x\) such that there are only \(3\) cards with \(x\) written on it in the given pile. The answer is such \(x\).
For each \(k \ (1 \leq k \leq N)\), count the number of cards with \(k\) written on them, then the problem can be solved.
Sample code (C++) :
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> count(n + 1);
for (int i = 0; i < 4 * n - 1; ++i) {
int a;
cin >> a;
count[a] += 1;
}
for (int i = 1; i <= n; ++i) {
if (count[i] == 3) {
cout << i << '\n';
}
}
return 0;
}
Sample code (Python) :
n = int(input())
count = [0] * (n + 1)
for a in map(int, input().split()):
count[a] += 1
for i in range(1, n + 1):
if count[i] == 3:
print(i)
posted:
last update: