CCF 201902 小明种苹果(续)
package cf;
import java.util.Scanner;
public class Mainapplexu {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
int T = 0, D = 0, E = 0;
for (int i = 0; i < n; i++) {
int b = sc.nextInt();
int temp = sc.nextInt();
boolean flag = true;
for(int j=1;j<b;j++) {
int num = sc.nextInt();
if(num<=0)
temp+=num;
else {
if(temp>num) {
temp=num;
flag = false;
}
}
}
T+=temp;
if(flag==false) {
D++;
a[i]=1;
}
}
for(int i=0;i<n;i++) {
if(a[i]==1&&a[(i+1+n)%n]==1&&a[(i-1+n)%n]==1)
E++;
}
System.out.println(T+" "+D+" "+E);
}
}