| 比赛 |
2026.8.28 |
评测结果 |
AAAAATTTTT |
| 题目名称 |
无法拒绝孤独的她 |
最终得分 |
50 |
| 用户昵称 |
exil |
运行时间 |
11.359 s |
| 代码语言 |
C++ |
内存使用 |
9.92 MiB |
| 提交时间 |
2026-08-28 10:55:15 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[500005],b[500005],c[500005];//c[i]表示第i个水塔与第i+1个水塔的管道容量
int shui[500005];
signed main(){
freopen("cantrefuse.in","r",stdin);
freopen("cantrefuse.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,q;
cin>>n>>q;
int aa=0,bb=0,cc=0;
int e=0;
for(int i = 1;i<=n;i++){
cin>>a[i];
if(a[i]!=0)aa=1;
}
for(int i = 1;i<=n;i++){
cin>>b[i];
if(b[i]!=0)bb=1;
e+=min(b[i],a[i]);
}
for(int i = 1;i<n;i++){
cin>>c[i];
if(c[i]!=0)cc=1;
}
if(aa==0){
for(int i = 1;i<=q;i++){
int p,x,y,z;
cin>>p>>x>>y>>z;
cout<<0<<"\n";
}
return 0;
}
if(bb==0){
for(int i = 1;i<=q;i++){
int p,x,y,z;
cin>>p>>x>>y>>z;
cout<<0<<"\n";
}
return 0;
}
if(cc==0){
for(int i = 1;i<=q;i++){
int p,x,y,z;
cin>>p>>x>>y>>z;
e-=min(b[p],a[p]);
a[p]=x;
b[p]=y;
e+=min(b[p],a[p]);
cout<<e<<"\n";
}
return 0;
}
for(int i = 1;i<=q;i++){
int p,x,y,z;
cin>>p>>x>>y>>z;
int ans=0;
if(p==n){
a[p]=x,b[p]=y;
}
else{
a[p]=x,b[p]=y,c[p]=z;
}
for(int i = 1;i<=n;i++)shui[i]=a[i];
for(int i = 1;i<=n;i++){
ans+=min(shui[i],b[i]);
shui[i]-=min(shui[i],b[i]);
shui[i+1]+=min(c[i],shui[i]);
}
cout<<ans<<"\n";
}
return 0;
}