问题描述
思路
完整代码
#include<iostream>
using namespace std;
int main()
{
int N;
cin >> N;
int M;
int tree[N];
int new_tree[N];
bool drop[N] = {0};
int T = 0;
int D = 0;
int E = 0;
for( int i = 0; i < N; i++)
{
cin >> M;
int operation[M];
cin >> tree[i];
new_tree[i] = tree[i];
for( int j = 1; j < M; j++)
{
cin >> operation[j];
if(operation[j] <= 0)
{
new_tree[i] += operation[j];
}
else if( operation[j] < new_tree[i])
{
drop[i] = 1;
new_tree[i] = operation[j];
}
}
T += new_tree[i];
if( drop[i] == 1) D++;
}
for( int i = 1; i < N-1; i++)
{
if( drop[i-1] && drop[i] && drop[i+1])
E++;
}
if( drop[0] && drop[1] && drop[N-1]) E++;
if( drop[N-2] && drop[N-1] && drop[0]) E++;
cout << T << ' ' << D << ' '<< E;
return 0;
}
提交截图