QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#106945 | #6370. Slot Machine | rgnerdplayer | WA | 2ms | 4148kb | C++20 | 1.7kb | 2023-05-19 21:00:40 | 2023-05-19 21:00:43 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
auto solve = [&]() {
constexpr int N = 1e5, INF = 1e9;
int ans = INF;
int n;
cin >> n;
vector<map<int, int>> boxes(n);
array<array<int, 2>, N + 1> mn;
mn.fill({INF, INF});
for (int i = 0; i < n; i++) {
int c;
cin >> c;
for (int j = 0; j < c; j++) {
int x;
cin >> x;
boxes[i][x]++;
}
int sz = boxes[i].size();
for (auto [x, y] : boxes[i]) {
if (y > 1) {
ans = min(ans, sz + 1);
}
int k = sz;
for (auto &l : mn[x]) {
if (k < l) {
swap(k, l);
}
}
}
}
for (int i = 0; i < n; i++) {
vector<int> v;
for (auto [x, y] : boxes[i]) {
v.push_back(mn[x][y == mn[x][0]]);
}
if (n == 10) {
for (auto x : v) {
cout << x << ' ';
}
cout << '\n';
}
sort(v.rbegin(), v.rend());
for (int j = 0; j < int(v.size()); j++) {
ans = min(ans, v[j] + j + 1);
}
}
cout << ans << '\n';
};
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 4148kb
input:
7 4 1 2 3 4 1 1 1 2 1 3 1 4 7 4 7 4 4 7 7 4 1 5
output:
3
result:
wrong answer 1st numbers differ - expected: '2', found: '3'