#include<iostream>
#include<stdlib.h>
using namespace std;
struct tree {
int time;
int t;
int *a = (int*)malloc( 1000 * sizeof(int));
bool flag = false;
};
int main() {
int n;
long long sum = 0;
int count = 0;
int num = 0;
cin >> n;
struct tree trees[1000];
for (int i = 0; i < n; i++) {
cin >> trees[i].time;
cin >> trees[i].t;
for (int j = 0; j < trees[i].time - 1; j++) {
cin >> trees[i].a[j];
if (trees[i].a[j] <= 0) {
trees[i].t += trees[i].a[j];
}
else {
if (trees[i].t > trees[i].a[j]) {
trees[i].t = trees[i].a[j];
trees[i].flag = true;
}
}
}
sum += trees[i].t;
if (trees[i].flag == true)
count++;
}
for (int i = 0; i < n; i++) {
if (i == 0 && trees[n - 1].flag == true && trees[i].flag == true && trees[i + 1].flag == true) {
num++;
}
else if (i == n - 1 && trees[i - 1].flag == true && trees[i].flag == true && trees[0].flag == true) {
num++;
}
else if (trees[i - 1].flag == true && trees[i].flag == true && trees[i + 1].flag == true) {
num++;
}
}
cout << sum << " " << count << " " << num;
return 0;
}
CCFCSP-20190902小明种苹果(续)C/C++
最新推荐文章于 2024-07-15 21:33:54 发布