当前位置:网站首页>~6. ccf 2021-09-1 数组推导
~6. ccf 2021-09-1 数组推导
2022-07-26 14:00:00 【叶萧白】
题目描述

输入

输出

样例输入
样例一:
6
0 0 5 5 10 10
样例二:
7
10 20 30 40 50 60 75
样例输出
样例一:
30
15
样例二:
285
285
子任务

源代码
#include <iostream>
using namespace std;
int main(){
int n;
cin>>n;
int *rmax=new int [n+1];
int *rmin=new int [n+1];
int result_max=0;
int result_min=0;
int temp=0;
int temp2=0;
for (int i = 0; i < n; i++) {
cin>>temp;
if (temp==temp2){
rmax[i]=temp;
rmin[i]=0;
} else{
rmax[i]=temp;
rmin[i]=temp;
}
temp2=temp;
}
for (int i = 0; i < n; i++) {
result_max+=rmax[i];
result_min+=rmin[i];
}
cout<<result_max<<endl;
cout<<result_min<<endl;
return 0;
}
边栏推荐
- IDEA(warning)No artifacts configured
- C语言_结构体和数组的结合
- [oauth2] v. oauth2loginauthenticationfilter
- Book download | introduction to lifelong supervised learning in 2022, CO authored by meta AI, CMU and other scholars, 171 Pages pdf
- C语言贪吃蛇-链表和指针练习
- TDSQL-C Serverless:助力初创企业实现降本增效
- .net6 encounter with the League of heroes - create a game assistant according to the official LCU API
- Difference between base addressing and index addressing
- 基于双层主题模型的技术演化分析框架及其应用
- Feixin, which lasted 15 years and had 500million users, was completely dead
猜你喜欢

重押海外:阿里、京东、顺丰再拼“内力”

最新战报:十项认证,五项最佳实践

TDSQL-C Serverless:助力初创企业实现降本增效

MySql的DDL和DML和DQL的基本语法

Circular queue (implemented in C language)

基于用户画像的在线健康社区用户流失预测研究

Re bet overseas: Alibaba, jd.com and SF again fight for "internal power"

IDEA(warning)No artifacts configured
![[oauth2] VIII. Configuration logic of oauth2 login -oauth2loginconfigurer and oauth2clientconfigurer](/img/7e/4f652c4d3d72ad563ddbc1c1f1f50b.png)
[oauth2] VIII. Configuration logic of oauth2 login -oauth2loginconfigurer and oauth2clientconfigurer

Videojs to canvas pause, play, switch video
随机推荐
C语言_结构体指针变量引入
421. Maximum XOR value of two numbers in the array
技术分享 | 需要小心配置的 gtid_mode
Flink SQL(三) 连接到外部系统System和JDBC
基于多任务深度学习的实体和事件联合抽取模型
力扣------字符串中的单词数
Meeting seating and submission for approval of OA project
Zhou Wei: look for non consensual investment opportunities to accompany the founding team that delays satisfaction
404 pages and routing hooks
周伟:寻找非共识性投资机会,陪伴延迟满足的创始团队
Circular queue (implemented in C language)
基于SPO语义三元组的疾病知识发现
搞懂MySQL的数据类型中长度含义
mysql5.7通过文件zip方式安装-九五小庞
Videojs to canvas pause, play, switch video
Comparator (interface between comparable and comparator)
Inspiration from brain: introduction to synaptic integration principle in deep neural network optimization
Segmentation fault (core dumped)
2022-07-26 Daily: the first anniversary of the establishment of alphafold DB database, research on the lighting point of official promotion
GDB common commands