博客
关于我
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;}
你可能感兴趣的文章
MySQL5.7.18主从复制搭建(一主一从)
查看>>
MySQL5.7.19-win64安装启动
查看>>
mysql5.7.19安装图解_mysql5.7.19 winx64解压缩版安装配置教程
查看>>
MySQL5.7.37windows解压版的安装使用
查看>>
mysql5.7免费下载地址
查看>>
mysql5.7命令总结
查看>>
mysql5.7安装
查看>>
mysql5.7性能调优my.ini
查看>>
MySQL5.7新增Performance Schema表
查看>>
Mysql5.7深入学习 1.MySQL 5.7 中的新增功能
查看>>
Webpack 之 basic chunk graph
查看>>
Mysql5.7版本单机版my.cnf配置文件
查看>>
mysql5.7的安装和Navicat的安装
查看>>
mysql5.7示例数据库_Linux MySQL5.7多实例数据库配置
查看>>
Mysql8 数据库安装及主从配置 | Spring Cloud 2
查看>>
mysql8 配置文件配置group 问题 sql语句group不能使用报错解决 mysql8.X版本的my.cnf配置文件 my.cnf文件 能够使用的my.cnf配置文件
查看>>
MySQL8.0.29启动报错Different lower_case_table_names settings for server (‘0‘) and data dictionary (‘1‘)
查看>>
MYSQL8.0以上忘记root密码
查看>>
Mysql8.0以上重置初始密码的方法
查看>>
mysql8.0新特性-自增变量的持久化
查看>>