博客
关于我
CCF 201909-2 小明种苹果(续)满分代码
阅读量:307 次
发布时间:2019-03-03

本文共 977 字,大约阅读时间需要 3 分钟。

作者:its_ycm 来源:CSDN 原文:https://blog.csdn.net/its_ycm/article/details/110424862版权声明:本文为博主原创文章,转载请附上博文链接!

试题编号: 201909-2

试题名称: 小明种苹果(续)
时间限制: 1.0s
内存限制: 512.0MB
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

输入

44 74 -7 -12 -55 73 -8 -6 59 -45 76 -5 -10 60 -25 80 -6 -15 59 0
54 10 0 9 04 10 -2 7 02 10 04 10 -3 5 04 10 -1 8 0

解法如下:

在这里插入图片描述

#include
using namespace std;const int N = 1000; int main(){ int n,t,s=0,a,D=0,E=0; cin>>n; int drop[N]={ 0}; int b[N+2]; for(int j=1;j<=n;++j) { cin >> t;//t记录每行第一个数 for(int i=0;i
>b[i]; if(i==0) a=b[0];//a记录每段苹果数 else if(b[i]>0){ if(a>b[i]) drop[j] = 1; a=b[i]; } else a=a+b[i]; } s = s+a; if(drop[j]==1) D++; } for(int j=1;j<=n;++j){ //此处的排序只能这样,不可以从123开始,一定要有判断当j==1||j==n时。 if(j==1&&drop[n]&&drop[1]&&drop[2]) E++; else if(j==n&&drop[n-1]&&drop[n]&&drop[1]) E++; else if(j!=1&&j!=n&&drop[j-1]&&drop[j]&&drop[j+1]) E++; } cout << s << " " << D << " " << E << " " << endl; return 0;}
你可能感兴趣的文章
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named 'pandads'
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>