QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#790005 | #9422. Two-star Contest | snow_mikumiku | WA | 28ms | 3980kb | C++14 | 1.9kb | 2024-11-27 23:32:37 | 2024-11-27 23:32:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
struct EV {
vector <int> sco;
int id;
int star;
LL tot;
bool operator < (EV &a) {
return star < a.star;
}
};
void solve()
{
LL n, m, k;
cin >> n >> m >> k;
vector <EV> p(n + 1);
map <int, LL> mxst;
for(int i = 1; i <= n; i++) {
p[i].id = i;
cin >> p[i].star;
p[i].sco.resize(m);
for(int j = 0; j < m; j++) {
cin >> p[i].sco[j];
if(p[i].sco[j] > 0) p[i].tot += p[i].sco[j];
}
mxst[p[i].star] = max(mxst[p[i].star], p[i].tot);
}
sort(p.begin() + 1, p.end());
LL up = 0;
mxst[0] = 0;
for(int i = 1; i <= n; i++)
{
auto it = mxst.lower_bound(p[i].star);
LL mx, mn;
mx = (*it).second;
--it;
mn = (*it).second + 1;
if(p[i].tot >= mn) {
for(auto& c: p[i].sco) {
if(c == -1) c = 0;
}
}
else {
LL D = mn - p[i].tot;
for(auto& c: p[i].sco) {
if(c == -1) {
c = min(D, k);
D -= c;
}
}
if(D > 0) {
cout << "No\n";
return;
}
}
LL sum = 0;
for(auto c: p[i].sco) sum += c;
mxst[p[i].star] = max(mxst[p[i].star], sum);
}
auto cmp = [](EV& a, EV& b) -> bool {
return a.id < b.id;
};
sort(p.begin() + 1, p.end(), cmp);
cout << "Yes\n";
for(int i = 1; i <= n; i++) {
for(auto c: p[i].sco) {
cout << c << ' ';
}
cout << '\n';
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while(t--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
input:
5 3 4 5 5 1 3 -1 -1 2 -1 5 -1 5 3 3 -1 -1 4 2 3 10 10000 5 0 -1 1 10 10 10 2 3 10 10 1 2 3 100 4 5 6 2 3 10 100 1 2 3 10 4 5 6 2 3 10000 100 -1 -1 -1 1 -1 -1 -1
output:
Yes 1 3 5 3 0 5 0 5 3 4 0 4 No Yes 1 2 3 4 5 6 No Yes 2 0 0 1 0 0
result:
ok ok 5 cases (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 28ms
memory: 3980kb
input:
1013 3 2 1 1 -1 -1 2 0 1 3 -1 -1 4 8 96295 302790137 -1 849 -1 -1 33907 7926 9461 70117 695984050 -1 -1 56792 -1 -1 -1 19527 -1 302790137 12828 30553 40825 67577 91517 77952 55631 63781 302790137 29385 -1 -1 -1 750 -1 -1 -1 2 6 72716304 892657961 -1 -1 66436933 -1 45419040 55642613 892657961 -1 6271...
output:
No Yes 0 849 0 0 33907 7926 9461 70117 96295 96295 56792 96295 75461 0 19527 0 12828 30553 40825 67577 91517 77952 55631 63781 29385 0 0 0 750 0 0 0 Yes 0 0 66436933 0 45419040 55642613 0 62712753 0 21765515 56544945 12385026 Yes 975402536 975402536 975402536 975402536 975402536 248560376 0 0 ...
result:
wrong answer Participant fails to find an answer while the jury found one. (test case 1)