其他分享
首页 > 其他分享> > CCF认证 2019-9 小明种苹果

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;
}

标签:count2,小明种,int,sum,++,2019,&&,CCF,scanf
来源: https://blog.csdn.net/shadiao_boy/article/details/121342061