import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<Boolean> arr = new ArrayList<>(); //存储树是否落果
int N = sc.nextInt();
int apples = 0, treeNum = 0, applesAll = 0, E = 0;
boolean flag;
for (int i = 0; i < N; i++) {
flag = false; //假设树不落果
int m = sc.nextInt();
int a = sc.nextInt();
if (a > 0) {
apples = a; //树初始果数
for (int j = 1; j < m; j++) {
int b = sc.nextInt();
if (b <= 0) {
apples = apples + b;//如果b小于等于0,则表示果数减掉疏果数
} else {
if (apples > b) {
flag = true; //树落果
apples = apples - (apples - b);//果数减去落果数
}
}
}
}
else
break;
if (flag) {
arr.add(true);
treeNum++; //落果的树的数量加1
}
else
arr.add(false);
applesAll = apples + applesAll;
}
for(int i =0;i<arr.size();i++){
//判断下标为i的树是否落果
if(arr.get(i)){
if(arr.get(i)&&arr.get((i+1)%arr.size())&&arr.get((i+2)%arr.size()))
E++;
}
}
System.out.println(applesAll + " " + treeNum + " " + E);
}
}
此题需要注意一个树有可能会有几次落果,所以在统计落果树的数量时可能会出现错误