QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#293076#7964. 转化FamiglistmoWA 45ms20164kbC++171.4kb2023-12-28 21:25:182023-12-28 21:25:19

Judging History

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

  • [2023-12-28 21:25:19]
  • 评测
  • 测评结果:WA
  • 用时:45ms
  • 内存:20164kb
  • [2023-12-28 21:25:18]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=4e5+5;

char buf[1<<23],*p1=buf,*p2=buf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
int read(){
    int s=0,w=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}
    while(isdigit(ch))s=s*10+(ch^48),ch=getchar();
    return s*w;
}

vector<int>vec;
int a[N],b[N],c[N];
int n;

signed main(){
    n=read();
    for(int i=1;i<=n;++i)a[i]=read();
    for(int i=1;i<=n;++i)b[i]=read();
    for(int i=1;i<=n;++i)c[i]=read();

    int fre=0,cst=0;
    for(int i=1;i<=n;++i)
        if(a[i]) fre+=min(a[i]+c[i],b[i]);
        else if(b[i]) cst+=min(c[i]+1,b[i])-1;

    for(int i=1;i<=n;++i)
        if(a[i]){
            if(!fre) printf("%lld ",a[i]+c[i]);
            else printf("%lld ",fre+cst+a[i]+c[i]-min(a[i]+c[i],b[i]));
        }else if(b[i]){
            if(!fre) printf("0 ");
            else printf("%lld ",fre+cst+c[i]-(min(c[i]+1,b[i])-1));
        }else{
            if(!fre) printf("0 ");
            else printf("%lld ",fre+cst);
        }

    int ans=0,cnt=fre+cst;
    for(int i=1;i<=n;++i)
        if(a[i])ans+=a[i]+c[i];
        else if(b[i]&&fre)ans+=c[i];
        else if(c[i])vec.push_back(c[i]);

    sort(vec.begin(),vec.end());
    while(vec.size()&&cnt)
        ans+=vec.back(),vec.pop_back(),--cnt;

    printf("\n%lld\n",ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 35ms
memory: 15268kb

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: 45ms
memory: 20164kb

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:

150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613...

result:

wrong answer 1st lines differ - expected: '389246793 773056414 285033292 ...47596 273937941 15883376 150613', found: '150613 150613 150613 150613 15...13 150613 150613 150613 150613 '