QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#546913 | #7964. 转化 | wangjingheng# | WA | 108ms | 35160kb | C++20 | 1.5kb | 2024-09-04 15:49:49 | 2024-09-04 15:49:49 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define db long double
using namespace std;
const int N=5e5+10;
int a[N],b[N],c[N],f[N],s[N],ss[N];
array<int,3> w[N];
void solve(){
int n;cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=n;i++) cin>>c[i];
for(int i=1;i<=n;i++) cin>>b[i];
for(int i=1;i<=n;i++){
//转移
if(a[i]==0){
f[i]=min(b[i]+1,c[i])-1;
f[i]=max(f[i],0ll);
ss[i]=ss[i-1]+f[i];
s[i]=s[i-1];
}
else{
if(c[i]<=a[i])f[i]=c[i];
else{
int mid=c[i]-a[i];
mid=min(mid,b[i]);
f[i]=a[i]+mid;
}
ss[i]=ss[i-1];
s[i]=f[i]+s[i-1];
}
}
for(int i=1;i<=n;i++){
if(a[i]){
int res=a[i]+b[i]+s[n]-f[i];
if(ss[n]&&s[n]){
res+=ss[n];
}
cout<<res<<" ";
}
else{
int res=b[i]+s[n];
if(s[n]&&ss[n]) res+=ss[n]-f[i];
if(!s[n]) res=0;
cout<<res<<" ";
}
}
int ans=0,cnt=0;
cout<<"\n";
for(int i=1;i<=n;i++){
w[i]={c[i],a[i],b[i]};
if(a[i])
ans+=a[i]+b[i],cnt+=c[i];
}
sort(w+1,w+n+1);
for(int i=n;i>=1;i--){
auto [cc,aa,bb]=w[i];
if(!aa){
if(cnt) ans+=bb,cnt+=cc;
}
}
cout<<ans;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
// int T;cin>>T;
// while(T--)
solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 108ms
memory: 34908kb
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: 89ms
memory: 35160kb
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:
wrong answer 2nd lines differ - expected: '115186454532787', found: '160138825249410'