QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#767267#7964. 转化yzy_21WA 256ms11448kbC++141.4kb2024-11-20 20:23:442024-11-20 20:23:52

Judging History

你现在查看的是最新测评结果

  • [2024-11-20 20:23:52]
  • 评测
  • 测评结果:WA
  • 用时:256ms
  • 内存:11448kb
  • [2024-11-20 20:23:44]
  • 提交

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], b[i]--, c[i] = 0;
                int add = min(a[i], b[i]);
                sum += add, a[i] -= add, b[i] -= add;
            }
            else if(sum > 0 and c[i] > 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";
    for(int i = 1; i <= n; ++i) sum += a[i];
    for(int i = 0; i < min<int>(sum, lst.size()); ++i) {
        sum += lst[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: 0
Wrong Answer
time: 256ms
memory: 11448kb

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:

60073965108448 60073217061605 60073217061605 60073226413102 60073217061605 60073533422732 60073272813965 60073217061605 60073589044064 60073528864555 60073217061605 60073217061605 60073693351387 60073217061605 60073217061605 60073411870846 60073295019330 60073217061605 60073376233730 60073217061605 ...

result:

wrong answer 1st lines differ - expected: '60073965049724 60073472376204 ...4 60073701685447 60073472376204', found: '60073965108448 60073217061605 ... 60073446370849 60073217061605 '