QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#290113 | #7964. 转化 | daydream# | WA | 81ms | 12900kb | C++20 | 1.2kb | 2023-12-24 13:40:25 | 2023-12-24 13:40:26 |
Judging History
answer
#include<bits/stdc++.h>
#define db double
#define LL long long
#define pb push_back
#define eb emplace_back
#define pli pair<LL,int>
#define pii pair<int,int>
#define fr first
#define sc second
#define mp make_pair
using namespace std;
const int dx[]={0,1,0,-1,1,1,-1,-1},
dy[]={1,0,-1,0,1,-1,1,-1};
int n;
void solve()
{
cin>>n;vector<int> a(n+1),b(n+1),c(n+1),ex(n+1);
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];
LL sum1=0,sum2=0;
for(int i=1;i<=n;++i)
{
if(a[i]) a[i]+=c[i],c[i]=0,sum1+=min(a[i],b[i]);
else if(b[i]&&c[i]) sum2+=max(0,min(b[i]-1,c[i]));
}
for(int i=1;i<=n;++i)
{
LL ans=sum1+a[i]-min(a[i],b[i]);
if(sum1) ans+=sum2;
if(!a[i]) ans+=c[i]-max(0,min(b[i]-1,c[i]));
cout<<ans<<' ';
}
cout<<'\n';
LL sum=0,tot=0;int cnt=0;vector<LL> vt;
for(int i=1;i<=n;++i)
if(a[i]) sum+=a[i];
else if(!b[i]) ++cnt,vt.pb(c[i]);
else tot+=c[i];
vt.pb(tot);++cnt;
sort(vt.begin(),vt.end(),greater<LL>());
for(int i=1;i<cnt;++i) vt[i]+=vt[i-1];
if(cnt) sum+=vt[min(cnt+0ll,sum)-1];
cout<<sum<<'\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int TT=1;
// cin>>TT;
for(;TT;--TT) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 81ms
memory: 8560kb
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: 0
Accepted
time: 67ms
memory: 12900kb
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:
ok 2 lines
Test #3:
score: -100
Wrong Answer
time: 76ms
memory: 12836kb
input:
351493 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 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 0 0 0 0 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
599928111 417141936 854896025 376367102 774244714 431347641 604428665 574576714 470717519 508427611 661004235 780213577 84639091 782348432 977630323 52634924 626665121 482558683 636948807 603433753 409075001 417850332 684775391 679542511 719331660 492363039 456376909 467979366 476324957 877501995 64...
result:
wrong answer 2nd lines differ - expected: '131418054091667', found: '175884846847709'