QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#106935 | #6370. Slot Machine | rgnerdplayer | WA | 10ms | 3612kb | C++20 | 1.6kb | 2023-05-19 20:36:48 | 2023-05-19 20:37:28 |
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 INF = 1e9;
int ans = INF;
int n;
cin >> n;
vector<map<int, int>> boxes(n);
map<int, set<pair<int, int>>> other;
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]++;
}
for (auto [x, y] : boxes[i]) {
if (y > 1) {
ans = min(ans, int(boxes[i].size()) + 1);
}
other[x].emplace(y, i);
}
}
for (int i = 0; i < n; i++) {
vector<int> v;
for (auto [x, y] : boxes[i]) {
int need = INF;
for (auto [c, j] : other[x]) {
if (i == j) {
continue;
}
need = c;
break;
}
v.push_back(need);
}
sort(v.rbegin(),v.rend());
assert(v.size() == boxes[i].size());
for (int j = 0; j < int(v.size()); j++) {
ans = min(ans, v[j] + j + 1);
}
}
cout << ans << '\n';
};
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3452kb
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:
2
result:
ok 1 number(s): "2"
Test #2:
score: -100
Wrong Answer
time: 10ms
memory: 3612kb
input:
10 1 971 1 472 1 799 1 68 1 729 1 592 1 616 1 148 1 188 99991 18 79 923 610 734 650 745 482 627 651 914 251 785 787 949 204 400 2 365 569 623 536 508 341 398 840 371 450 332 223 36 578 850 857 192 474 309 933 457 162 200 140 802 462 40 957 553 640 302 748 532 323 593 239 657 425 17 584 924 903 413 3...
output:
81
result:
wrong answer 1st numbers differ - expected: '993', found: '81'