QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#871474 | #9557. Temperance | 1903331632 | WA | 0ms | 3584kb | C++23 | 1.5kb | 2025-01-25 20:50:00 | 2025-01-25 20:50:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 10;
#define pii pair<int, int>
#define lowbit(x) (x & (-x))
// int x[N], y[N], z[N];
int n;
void solve()
{
cin >> n;
map<int, int> x, y, z;
for (int i = 0; i < n; i++)
{
int t1, t2, t3;
cin >> t1 >> t2 >> t3;
x[t1]++;
y[t2]++;
z[t3]++;
}
priority_queue<int, vector<int>, greater<int>> q1, q2, q3;
int s1 = n;
int s2 = n;
int s3 = n;
for (auto t : x)
q1.push(t.second);
for (auto t : y)
q2.push(t.second);
for (auto t : z)
q3.push(t.second);
for (int i = 0; i < n; i++)
{
while (q1.size() && q1.top() < i + 1)
{
int t = q1.top();
q1.pop();
s1--;
if (t - 1 >= 1)
q1.push(t - 1);
}
while (q2.size() && q2.top() < i + 1)
{
int t = q2.top();
q2.pop();
s2--;
if (t - 1 >= 1)
q2.push(t - 1);
}
while (q3.size() && q3.top() < i + 1)
{
int t = q3.top();
q3.pop();
s3--;
if (t - 1 >= 1)
q3.push(t - 1);
}
cout << n - max(s1, max(s2, s3)) << ' ';
}
cout << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--)
solve();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
input:
2 5 1 1 1 1 1 2 1 1 3 2 3 5 2 2 4 3 1 1 1 2 2 2 3 3 3
output:
0 0 2 5 5 0 3 3
result:
ok 8 numbers
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3584kb
input:
16 1 1 1 1 2 1 1 1 1 1 100000 3 1 1 1 1 1 100000 1 100000 1 4 1 1 1 1 1 100000 1 100000 1 1 100000 100000 5 1 1 1 1 1 100000 1 100000 1 1 100000 100000 100000 1 1 6 1 1 1 1 1 100000 1 100000 1 1 100000 100000 100000 1 1 100000 1 100000 7 1 1 1 1 1 100000 1 100000 1 1 100000 100000 100000 1 1 100000 ...
output:
0 0 0 0 0 0 0 0 0 0 0 0 1 1 5 0 0 0 2 6 6 0 0 0 3 7 7 7 0 0 0 0 8 8 8 8 0 0 0 0 0 0 0 0 0 0 0 0 1 1 5 0 0 0 2 6 6 0 0 0 3 7 7 7 0 0 0 0 8 8 8 8
result:
wrong answer 13th numbers differ - expected: '0', found: '1'