QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#680148 | #9422. Two-star Contest | HTensor# | WA | 0ms | 3544kb | C++23 | 2.2kb | 2024-10-26 19:57:27 | 2024-10-26 19:57:29 |
Judging History
answer
#include <bits/stdc++.h>
#define dd(x) cout << #x << "\n"
#define d(x) cout << #x << ": " << x << "\n"
#define SZ(x) ((int)(x).size())
using namespace std;
#define int long long
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vii = vector<vector<int>>;
using a3 = array<int, 3>;
using ll = long long;
const int inf = 0x3f3f3f3f3f3f3f3fLL;
#define MULTI_TEST
struct C {
int s, id;
vector<int> sc;
bool operator<(const C b) {
return s > b.s;
}
// C(int _s, vector<int> _sc) : s(_s), sc(_sc) { }
};
void solve() {
int n, m, k; cin >> n >> m >> k;
vector<C> c(n + 1);
for(int i = 1; i <= n; i++) {
int s; vector<int> sc;
cin >> s;
for(int j = 1; j <= m; j++) {
int x; cin >> x;
sc.push_back(x);
}
c[i] = {s, i, sc};
}
sort(c.begin() + 1, c.end());
vector<int> add(n + 1);
int minx = inf, nowMinx = inf;
for(int i = 1; i <= n; i++) {
if(c[i].s != c[i - 1].s) {
minx = nowMinx;
}
int sum = 0;
for(auto v : c[i].sc) {
if(v != -1) sum += v;
else {
add[i] += k;
}
}
if(sum >= minx) {
cout << "No\n";
return ;
}
add[i] = min(minx - sum - 1, add[i]);
nowMinx = min(nowMinx, sum + add[i]);
}
cout << "Yes\n";
sort(c.begin() + 1, c.end(), [](C a, C b) { return a.id < b.id; });
for(int i = 1; i <= n; i++) {
for(auto v : c[i].sc) {
if(v != -1) cout << v << " ";
else {
int x = min(add[i], k);
add[i] -= x;
cout << x << " ";
}
}
cout << "\n";
}
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
#ifdef MULTI_TEST
int T; cin >> T;
#else
int T = 1;
#endif
while(T--) solve();
return 0;
}
/*
1
3 4 5
5 1 3 -1 -1
2 -1 5 -1 5
3 3 -1 -1 4
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
*/
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3544kb
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 5 5 5 1 5 3 2 0 4 No Yes 1 2 3 4 5 6 No Yes 10000 10000 10000 10000 10000 9999
result:
wrong answer Participant cannot satisfy the constraint. (test case 1)