RT,代码如下,违规紫衫
#include<bits/stdc++.h>
using namespace std;
long long n,m,a[10001],b[10001][3]={0};
int main ()
{
cin>>n>>m;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=m;i++) cin>>b[i][1];
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
if(a[i]>b[j][2] && b[j][1]>0)
{
int t=b[j][1]+b[j][2]-a[i];
if(t<=0)
{
a[i]+=b[j][1];
b[j][2]+=b[j][1];
b[j][1]=0;
}
else
{
a[i]+=b[j][1]-t;
b[j][2]+=b[j][1]-t;
b[j][1]=t;
}
}
for(int i=1;i<=n;i++) cout<<a[i]<<endl;
return 0;
}