QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#767308#7964. 转化yzy_21WA 250ms11360kbC++141.4kb2024-11-20 20:29:262024-11-20 20:29:27

Judging History

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

  • [2024-11-20 20:29:27]
  • 评测
  • 测评结果:WA
  • 用时:250ms
  • 内存:11360kb
  • [2024-11-20 20:29:26]
  • 提交

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, sum--;
                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] << " ";
    }
    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: 250ms
memory: 11360kb

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 60073217002881 60073217002881 60073226354378 60073217002881 60073533364007 60073272755241 60073217002881 60073588985340 60073528805830 60073217002881 60073217002881 60073693292662 60073217002881 60073217002881 60073411812122 60073294960606 60073217002881 60073376175006 60073217002881 ...

result:

wrong answer 1st lines differ - expected: '60073965049724 60073472376204 ...4 60073701685447 60073472376204', found: '60073965049724 60073217002881 ... 60073446312124 60073217002881 '