QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#614047 | #7964. 转化 | lym | WA | 132ms | 19604kb | C++20 | 1.8kb | 2024-10-05 15:26:51 | 2024-10-05 15:26:52 |
Judging History
answer
#include<bits/stdc++.h>
using i64 = long long;
#define int i64
void solve() {
int n;
std::cin >> n;
std::vector<std::array<int, 4> > a(n + 1);
std::vector<int> e(n + 1);
for (int i = 1; i <= n; i ++) {
std::cin >> a[i][0];
}
for (int i = 1; i <= n; i ++) {
std::cin >> a[i][1];
}
for (int i = 1; i <= n; i ++) {
std::cin >> a[i][2];
a[i][3] = i;
}
i64 sum = 0, res = 0;
for (int i = 1; i <= n; i ++) {
if (a[i][0] && a[i][1]) {
e[a[i][3]] = 1;
sum += a[i][0] + a[i][2];
res += std::min(a[i][0] + a[i][2], a[i][1]);
}
}
std::sort(a.begin() + 1, a.end(), [&](auto x, auto y) {
return x[1] > y[1];
});
for (int i = 1; i <= n; i ++) {
if (e[a[i][3]]) continue;
if (! a[i][0]) {
if (! res) continue;
res --;
sum += a[i][2];
res += std::min(a[i][2] + 1ll, a[i][1]);
} else if (! a[i][1]) { // a[i]
sum += a[i][0] + a[i][2];
}
}
std::vector<int> d(n + 1);
i64 op = 0;
res = 0;
for (int i = 1; i <= n; i ++) {
if (a[i][0] && a[i][1]) {
d[a[i][3]] = std::min(a[i][1], a[i][0] + a[i][1]);
op += d[a[i][3]];
}
}
for (int i = 1; i <= n; i ++) {
if (e[a[i][3]]) continue;
if (! a[i][0]) {
if (! a[i][1]) continue;
op --;
d[a[i][3]] = std::min(a[i][2] + 1ll, a[i][1]) - 1;
op += std::min(a[i][2] + 1ll, a[i][1]);
} else if (! a[i][1]) { // a[i]
d[a[i][3]] = 0;
continue;
}
}
std::sort(a.begin() + 1, a.end(), [&](auto x, auto y) {
return x[3] < y[3];
});
for (int i = 1; i <= n; i ++) {
if (a[i][0]) {
std::cout << a[i][1] + a[i][2] + op - d[i] << ' ';
}
}
std::cout << '\n';
std::cout << sum << '\n';
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t = 1;
//std::cin >> t;
while (t --) {
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 132ms
memory: 19604kb
input:
351493 0 37836791 46095966 46912389 21595941 0 3 86568894 3 0 0 0 0 39910208 0 2 4 86885825 1 67660833 0 24488082 52447896 0 67190942 70457491 11166998 90470470 11095822 0 0 5 47222930 2 49736354 0 0 0 77339472 0 5 3 0 25347727 0 3 2 0 48844622 0 65142757 1 73733079 80634668 46683173 0 31644647 9760...
output:
73237989536046 73237925994103 73237967679714 73238194462124 73238187961992 73238025419592 73238498956203 73237922252180 73238319528078 73238130121256 73238137619468 73238363383553 73238178484369 73238151844117 73238120741157 73237988235836 73238139244480 73238064702855 73238178647963 73238061416695 ...
result:
wrong answer 1st lines differ - expected: '60073965049724 60073472376204 ...4 60073701685447 60073472376204', found: '73237989536046 73237925994103 ... 73237973139957 73237984478465 '