题解如下:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n, m;
int a[10001] = {0};
bool f[10001] = {false};
bool drop(int index){
if(index == -1)
index = n - 1;
if(index == n)
index = 0;
return f[index];
}
int main(){
int i, j, dropnum = 0, con = 0, temp, sum = 0;
scanf("%d", &n);
for(i = 0; i < n; i++){
scanf("%d", &m);
for(j = 0; j < m; j++){
scanf("%d", &temp);
if(temp <= 0)
a[i] += temp;
else{
if(a[i] > temp){
if(!f[i]){
dropnum++;
f[i] = true;
}
a[i] = temp;
}
else
a[i] = temp;
}
}
sum += a[i];
}
for(i = 0; i < n; i++){
if(drop(i-1) && f[i] && drop(i+1))
con++;
}
printf("%d %d %d\n", sum, dropnum, con);
return 0;
}
网友评论