QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#768091 | #7964. 转化 | yzy_21 | WA | 257ms | 17504kb | C++14 | 1.4kb | 2024-11-21 00:30:34 | 2024-11-21 00:30:35 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
using pii = pair<int, int>;
signed main() {
int n;cin >> n;
vector<int> a(n + 1), b(n + 1), c(n + 1), lst, lst2;
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(b[i] > 0) lst.emplace_back(i);
else if(c[i] > 0) lst2.emplace_back(c[i]);
}
}
if(sum) for(auto i : lst) {
a[i] = 1 + c[i], sum--, c[i] = 0;
int add = min(a[i], b[i]);
sum += add, a[i] -= add, b[i] -= add;
}
for(int i = 1; i <= n; ++i) {
if(sum) cout << a[i] + c[i] + sum << " ";
else cout << a[i] << " ";
}
cout << "\n";
sort(begin(lst2), end(lst2), greater<int> ());
for(int i = 0; i < min<int>(sum, lst2.size()); ++i) {
sum += lst2[i];
}
for(int i = 1; i <= n; ++i) sum += a[i];
cout << sum << "\n";
return 0;
}
/*
如果a[i] > 0那么把c[i]先全变成a[i],
如果没有就考虑是否把别的换成a[i],换成i的前提是b[i] != 0,
如果不够的话应该优先给c[i]大的
最后答案就是所有都转化成i,然后用前缀和优化
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 257ms
memory: 12536kb
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:
60073965049724 60073472376204 60073472376204 60073481727701 60073472376204 60073788737330 60073528128564 60073472376204 60073844358663 60073784179153 60073472376204 60073472376204 60073948665985 60073472376204 60073472376204 60073667185445 60073550333929 60073472376204 60073631548329 60073472376204 ...
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 177ms
memory: 17504kb
input:
351493 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
389246793 773056414 285033292 35143062 150613 960166465 230310734 742299190 422307527 716629610 559282116 167517603 440667606 980062124 288964464 150613 37777273 995600801 890644898 919111990 697350089 651910449 818599875 248723392 345836780 145972754 169220149 798545767 375398590 724669763 34806631...
result:
wrong answer 2nd lines differ - expected: '115186454532787', found: '160138825249410'