本题比较简单,这里直接贴代码
#include <bits/stdc++.h>
using namespace std;
struct node1
{
int sum;//苹果总数
int op[1010];//对苹果树的m[i]个操作
int drop;//是否掉苹果
} apple[1010];
int N, i, j, m, T = 0, D = 0, E = 0;
int main()
{
scanf("%d", &N);
for(i=1; i<=N; i++)
{
scanf("%d", &m);
apple[i].drop = 0;
apple[i].sum = 0;
for(j=1; j<=m; j++)
{
scanf("%d", &apple[i].op[j]);
if(apple[i].op[j] > 0)
{
if(j == 1)
apple[i].sum = apple[i].op[j];
if(apple[i].op[j] < apple[i].sum)
{
apple[i].drop = 1;//掉落苹果
apple[i].sum = apple[i].op[j];
}
}
else
apple[i].sum += apple[i].op[j];
}
if(apple[i].drop)
D++; //统计D
T += apple[i].sum;//统计T
}
//求E
for(i=2; i<=N-1; i++)
{
if(apple[i].drop && apple[i-1].drop && apple[i+1].drop)
E++;
}
if(apple[N].drop && apple[1].drop && apple[2].drop)
E++;
if(apple[N-1].drop && apple[N].drop && apple[1].drop)
E++;
printf("%d %d %d", T, D, E);
return 0;
}