QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#767357#7964. 转化yzy_21WA 251ms12416kbC++141.4kb2024-11-20 20:41:032024-11-20 20:41:03

Judging History

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

  • [2024-11-20 20:41:03]
  • 评测
  • 测评结果:WA
  • 用时:251ms
  • 内存:12416kb
  • [2024-11-20 20:41:03]
  • 提交

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(b[i], c[i]);
        sum += add, b[i] -= add, c[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 = 1; i <= n; ++i) sum += a[i];
    for(int i = 0; i < min<int>(sum, lst2.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,然后用前缀和优化
*/

詳細信息

Test #1:

score: 0
Wrong Answer
time: 251ms
memory: 12416kb

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:

42483240748948 42482492702104 42482492702104 42482502053601 42482492702104 42483088424511 42482548454464 42482492702104 42482864684563 42483099129249 42482501878494 42482597790161 42483137500308 42482492702104 42482741381266 42482687511345 42482570659829 42482492702104 42482651874229 42482492702104 ...

result:

wrong answer 1st lines differ - expected: '60073965049724 60073472376204 ...4 60073701685447 60073472376204', found: '42483240748948 42482492702104 ... 42482954749026 42482529675492 '