写的像shi一样 纯娱乐 求调
#include<bits/stdc++.h>
using namespace std;
int a[5],b[5][25],s[5],ans,q,x,y;
int main(){
for(int i=1;i<=4;i++)
{
cin>>a[i];
}
for(int i=1;i<=4;i++)
{
for(int j=1;j<=a[i];j++)
{
cin>>b[i][j];
}
x=b[i][1];y=b[i][2];
int u=3;
a[i]-=2;
if(x==y&&a[i]-u==2)
{
s[i]+=x+y;
x=b[i][u];
u++;
y=b[i][u];
u++;
}
else
{
s[i]+=b[i][u];
}
while(u<a[i])
{
if(x>y)
{
x-=y;
s[i]+=y;
y=b[i][u];
u++;
}
else if(y>x)
{
y-=x;
s[i]+=x;
x=b[i][u];
u++;
}
else if(x==y&&a[i]-u>=2)
{
s[i]+=x+y;
x=b[i][u];
u++;
y=b[i][u];
u++;
}
else
{
s[i]+=b[i][u];
}
}
}
for(int i=1;i<=4;i++)
{
ans+=s[i];
}
cout<<ans;
return 0;
}