这是小蒟蒻的代码,调了很久没调出来,同学给的hack数据全过了,但是你谷一直全WA,求助
#include<bits/stdc++.h>
using namespace std;
int n, m, k;
inline int read()
{
int x = 0, f = 1;
char c = getchar();
while (c < '0' || c>'9')
{
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9')
{
x = (x << 3) + (x << 1) + (c ^ '0');
c = getchar();
}
return x * f;
}
priority_queue<int, vector<int>, greater<int> >p, ans;
priority_queue<pair<int, int> >q;
int main()
{
n = read();
m = read();
k = read();
for (int j = 1;j <= m;++j)
{
int x = read();
q.push(make_pair(-1, -x));
}
for (int i = 2;i <= n;++i)
{
for (int j = 1;j <= m;++j)
{
int x = read();
p.push(x);
}
int x = -q.top().second;
q.pop();
int y = p.top();
p.pop();
q.push(make_pair(-i, -(x + y)));
for (int j = 2;j <= k;++j)
{
int t1 = x + p.top();
int t2 = y - q.top().second;
if (t1 >= t2)
{
q.push(make_pair(-i, -t2));
q.pop();
}
else
{
q.push(make_pair(-i, -t1));
p.pop();
}
}
while (-q.top().first == i - 1)
{
q.pop();
}
while (!p.empty())
{
p.pop();
}
}
for (int i = 1;i <= k;++i)
{
ans.push(-q.top().second);
q.pop();
}
for (int i = 1;i <= k;++i) {
printf("%d ", ans.top()), ans.pop();
}
return 0;
}