import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] nn = new int[n];
int sum = 0;
List<Integer> list = new ArrayList<>();
for (int i = 0; i < n; i++) {
nn[i] = scanner.nextInt();
for (int j = 1; j < nn[i]+1; j++) {
list.add(scanner.nextInt());
}
int k = list.get(0);
boolean flag = false;
for (int j = 1; j < list.size(); j++) {
if (list.get(j)<=0){
k += list.get(j);
}else {
if (k != list.get(j)){
flag = true;
break;
}
k = list.get(j);
}
}
int c = 0;
for (int j = list.size()-1; j >=1 ; j--) {
if (list.get(list.size()-1) == 0){
if (list.get(j)<=0){
c++;
if (list.get(j-1)>0&&list.get(j)<0){
if (list.get(j-1)+c>0)
flag = true;
break;
}
}
}
}
int l = 0;
for (int j = list.size()-1; j >=0 ; j--) {
if (list.get(j)<=0){
l += list.get(j);
}else {
sum +=(list.get(j)+l);
break;
}
}
if (flag == true)
nn[i] = 1;
else
nn[i] = 0;
list.clear();
}
int add = 0;
int a = 0;
int b = 0;
for (int i = 0; i < n; i++) {
if (nn[i] == 1){
add++;
a++;
}else {
a = 0;
}
if (a>=3)
b++;
}
if (n>2){
if (nn[0] == 1 && nn[n-1] ==1){
if (nn[1] == 1 && nn[n-2] ==1)
b += 2;
if ((nn[1] == 0 && nn[n-2] ==1)||nn[1] == 1 && nn[n-2] ==0)
b++;
}
}
System.out.println(sum+"\t"+add+"\t"+b);
}
}
CCF(201909-2)—— 小明种苹果(续)
最新推荐文章于 2023-04-03 22:10:26 发布