CCF认证 2019-9 小明种苹果

#include<iostream>

using namespace std;

int n, m;

int a, first;

int sum = 0, s = 0;

int t, d, e;

int p[1001] = {0};

int count1 = 0, count2 = 0;


int main(){
	
	scanf("%d",&n);
	
	for(int i = 0; i < n; ++i) {
		scanf("%d",&m);
		scanf("%d",&first);
		sum = first;
		for(int j = 0; j < m - 1; ++j) {
			scanf("%d",&a);
			if(a < 0) sum += a;
			else if(a > 0) {
				if(sum > a) {
					sum = a;
					p[i] = 1;
				}
			}
					
		}
		
		s += sum;
	}
	
	for(int i = 0; i < n; ++i) {
		
		if(p[i] == 1) count1++;
		
	}
	
	for(int i = 1; i < n-1; ++i) {
		if(p[i-1] == 1 && p[i] == 1 && p[i+1] == 1) count2++;
	}
	
	if(p[n-1] == 1 && p[1] == 1 && p[2] == 1) count2++;
	if(p[n-2] == 1 && p[n-1] == 1 && p[1] == 1) count2++;
	
	printf("%d %d %d",s,count1,count2); 
	
	return 0;
}
上一篇:CCF-CSP 201703-2学生排队 一维数组满分题解


下一篇:CCF系考试模板