QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#767203 | #7964. 转化 | yzy_21 | WA | 252ms | 11540kb | C++14 | 1.5kb | 2024-11-20 20:10:29 | 2024-11-20 20:10:36 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int n;cin >> n;
vector<int> a(n + 1), b(n + 1), c(n + 1), lst;
int sum = 0;
for(int i = 1; i <= n; ++i) cin >> a[i];
for(int i = 1; i <= n; ++i) cin >> b[i];
for(int i = 1; i <= n; ++i) cin >> c[i];
for(int i = 1; i <= n; ++i) {
if(a[i]) {
a[i] += c[i];
c[i] = 0;
int add = min(a[i], b[i]);
sum += add;
a[i] -= add, b[i] -= add;
}
else {
if(sum > 0 and b[i] > 0) {
a[i] = 1 + c[i];
c[i] = 0;
int add = min(a[i], b[i]);
sum += add;
a[i] -= add, b[i] -= add;
}
else if(sum > 0) {
lst.emplace_back(c[i]);
}
}
}
sort(begin(lst), end(lst), greater<int> ());
for(int i = 1; i <= n; ++i) {
if(sum) cout << a[i] + c[i] + sum << " ";
else cout << a[i] + sum << " ";
}
cout << "\n";
int sum2 = 0;
for(auto x : lst) {
if(sum) {
sum2 += x + 1;
sum--;
}
}
cout << sum + sum2 << "\n";
return 0;
}
/*
如果a[i] > 0那么把c[i]先全变成a[i],
如果没有就考虑是否把别的换成a[i],换成i的前提是b[i] != 0,
如果不够的话应该优先给c[i]大的
最后答案就是所有都转化成i,然后用前缀和优化
*/
詳細信息
Test #1:
score: 0
Wrong Answer
time: 252ms
memory: 11540kb
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:
60073965166822 60073217119979 60073217119979 60073226471476 60073217119979 60073533481105 60073272872339 60073217119979 60073589102438 60073528922928 60073217119979 60073217119979 60073693409760 60073217119979 60073217119979 60073411929220 60073295077704 60073217119979 60073376292104 60073217119979 ...
result:
wrong answer 1st lines differ - expected: '60073965049724 60073472376204 ...4 60073701685447 60073472376204', found: '60073965166822 60073217119979 ... 60073446429222 60073217119979 '