import java.util.Scanner; public class Two { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); long T = 0, D = 0, E = 0; boolean[] drop = new boolean[N]; for(int i = 0; i < N; i++){ drop[i] = false; int m = sc.nextInt(); int subTot = 0; for(int j = 0; j < m; j++){ int sub = sc.nextInt(); if(sub > 0){ if(j == 0){ subTot = sub; }else if(subTot != sub){ D++; subTot = sub; drop[i] = true; } }else{ subTot += sub; } } T += subTot; } for(int i = 0; i < N; i++){ if(drop[i] && drop[(i + 1) % N] && drop[(i + 2) % N]){ E++; } } System.out.print(T + " " + D + " " + E); } } //4 // 4 74 -7 -12 -5 // 5 73 -8 -6 59 -4 // 5 76 -5 -10 60 -2 // 5 80 -6 -15 59 0 //5 // 4 10 0 9 0 // 4 10 -2 7 0 // 2 10 0 // 4 10 -3 5 0 // 4 10 -1 8 0
来源:51CTO
作者:大吉大利,今晚AC
链接:https://blog.csdn.net/lalala_HFUT/article/details/100862880