QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#876411 | #4269. Rainy Markets | hhoppitree | 0 | 1ms | 10064kb | C++17 | 873b | 2025-01-30 21:01:16 | 2025-01-30 21:01:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int a[N], b[N], c[N], f[N];
signed main() {
int n; scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
for (int i = 1; i < n; ++i) scanf("%d", &b[i]);
for (int i = 1; i < n; ++i) scanf("%d", &c[i]);
f[n] = a[n];
for (int i = n - 1; i >= 1; --i) {
f[i] = a[i] - max(b[i] - c[i] - f[i + 1], 0);
if (f[i] < 0) return 0 & puts("NO");
}
vector< array<int, 3> > res;
for (int i = 1; i < n; ++i) {
int t = min(b[i] - a[i], f[i + 1]);
res.push_back({a[i], b[i] - a[i] - t, t});
a[i + 1] -= t;
}
long long S = 0;
for_each(res.begin(), res.end(), [&](auto x) { S += x[0]; });
puts("YES"), printf("%lld\n", S);
for (auto [x, y, z] : res) printf("%d %d %d\n", x, y, z);
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 5
Accepted
time: 0ms
memory: 10056kb
input:
3 10 15 10 20 20 0 0
output:
NO
result:
ok IMPOSSIBLE
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 10064kb
input:
2 813741488 132495829 946237313 0
output:
YES 813741488 813741488 0 132495825
result:
wrong answer the cost you declared is 813741488, but expected 0
Subtask #2:
score: 0
Wrong Answer
Test #36:
score: 0
Wrong Answer
time: 1ms
memory: 10060kb
input:
3 10 15 10 20 20 0 11
output:
YES 15 10 0 10 5 5 10
result:
wrong answer the cost you declared is 15, but expected 5
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%