CCF [201909-2] 小明种苹果(续)

16 篇文章 0 订阅

在这里插入图片描述

//201909-2小明种苹果(续)
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;

int str[1001][1001];
int cir[1001];

int main()
{
	int n,m,i,j,k=0,t=0,d=0,e=0,sum;
	cin>>n;//n:苹果树的棵树
	for(i=0;i<n;i++)
	{
		cin>>m;
		str[i][0]=m;
		for(j=1;j<=m;j++)
		{
			cin>>str[i][j];			
		}
	}
	for(i=0;i<n;i++)
	{
		m=str[i][0];
		for(j=m;j>=1;j--)//求t  倒着往回数,数到第一个大于0的数就break; 
		{
			if(str[i][j]<=0)
				t+=str[i][j];
			else
			{
				t+=str[i][j];
				break;
			}
		}
		sum=0;             //求d 
		sum+=str[i][1];
		for(j=2;j<=m;j++)
		{
			if(str[i][j]<=0)
			{
				sum+=str[i][j];
			}	
			else
			{
				if(sum!=str[i][j])
				{
					d++;
					cir[i]=1;
				}	
				break;							
			}
		}
	}
//	if((cir[0]&&cir[1]&&cir[2])) //求e  这样写,得70,没看出为啥错来,有大佬看出来,敬请指点~ 
//		e++;
//	if(cir[1]&&cir[2]&&cir[3])
//		e++;
//	for(i=2;i<n;i++)
//	{
//		if((cir[i]&&cir[i+1]&&cir[i+2])
//		|| (cir[i]&&cir[i+1]&&cir[0])
//		|| (cir[i]&&cir[0]&&cir[1]))
//			e++;
//	}
	if(cir[n-2]&&cir[n-1]&&cir[0]) e++;//求e  这样写,100分! 
	if(cir[n-1]&&cir[0]&&cir[1]) e++;
	for(i=0;i<n;i++)
	{
		if(cir[i]&&cir[i+1]&&cir[i+2])
			e++;
	}
	
	cout<<t<<" "<<d<<" "<<e;
	return 0;
} 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值