QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#626374 | #9422. Two-star Contest | edhlii | WA | 21ms | 4240kb | C++14 | 1.7kb | 2024-10-10 07:19:09 | 2024-10-10 07:19:09 |
Judging History
answer
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
int testCase;
struct star {
int val, pos;
ll sum = 0;
};
bool cmp(const star &a, const star &b) {
if (a.val == b.val) return a.sum < b.sum;
return a.val < b.val;
}
void process() {
int n, m;
ll k;
ll preSum = 0;
cin >> n >> m;
cin >> k;
vector<star> s(n);
vector<vector<ll> > p(n, vector<ll>(m));
for (int i = 0; i < n; i++) {
cin >> s[i].val;
s[i].pos = i;
for (int j = 0; j < m; j++) {
cin >> p[i][j];
if (p[i][j] != -1) s[i].sum += p[i][j];
}
}
sort(s.begin(), s.end(), cmp);
for (int e = 0; e < n; e++) {
int i = s[e].pos;
// cout << s[e].val << " " << s[e].pos << " \n";
if (e == 0) {
for (int j = 0; j < m; j++) {
if (p[i][j] == -1) p[i][j] = 0;
}
preSum = s[e].sum;
// cout << preSum << " \n";
continue;
}
ll needingSum = preSum + 1 - s[e].sum;
// cout<<needingSum<<" ";
for (int j = 0; j < m; j++) {
if (p[i][j] == -1) {
p[i][j] = min(k, needingSum);
needingSum -= k;
s[e].sum += p[i][j];
}
if (needingSum < 0) needingSum = 0;
}
if (needingSum > 0) {
cout << "No\n"; return;
}
preSum = s[e].sum;
// cout << preSum << " ";
}
cout << "Yes\n";
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) cout << p[i][j] << " ";
cout << "\n";
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("a.inp", "r", stdin);
freopen("a.out", "w", stdout);
#endif
cin >> testCase;
while (testCase--) process();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
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 1 0 0 0 0 0
result:
ok ok 5 cases (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 21ms
memory: 4240kb
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:
Yes 0 0 0 1 1 1 Yes -92124 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 -14090346 0 66436933 0 45419040 55642613 0 62712753 0 21765515 56544945 12385026 Yes 975402536 975402536 975402536 97540...
result:
wrong answer Integer parameter [name=q_{i, j}] equals to -92124, violates the range [0, 96295] (test case 2)