当前位置:网站首页>CCF CSP 202109-1数组推导
CCF CSP 202109-1数组推导
2022-06-10 21:21:00 【Brienzz】
#include<iostream>
#include<cstdlib>
using namespace std;
typedef long long ll;
int A[100+5];
int B[100+5];
int main(){
int n;
scanf("%d",&n);
int summax = 0;
for(int i=1;i<=n;i++){
scanf("%d",&B[i]);
summax += B[i];
}
int recent = A[1]= B[1];
int summin = B[1];
for(int i=2;i<=n;i++){
if(B[i]==recent){
summin += 0;
}else{
summin +=B[i];
}
recent = B[i];
}
cout<<summax<<endl<<summin<<endl;
return 0;
}
或者:
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
int n;
int Bi,Bi_1;
int summin,summax ;
cin>>n;
cin>>Bi;
summin = summax = Bi;
Bi_1 = Bi;
for(int i=1;i<n;i++){
cin>>Bi;
if(Bi>Bi_1){
summin += Bi;
summax += Bi;
}
if(Bi==Bi_1){
summax += Bi;
}
Bi_1 = Bi;
}
cout<<summax<<endl<<summin;
return 0;
}边栏推荐
- 【生成对抗网络学习 其一】经典GAN与其存在的问题和相关改进
- Array rotate array
- Variables (automatic variables, static variables, register variables, external variables) and memory allocation of C malloc/free, calloc/realloc
- 如何激发文化创新的活力和驱动力
- Record (II)
- [debug] could not find ref wiht POC XXX
- 数组 从指定长度位旋转数组
- Array move 0
- 《暗黑破坏神不朽》数据库资料站地址 暗黑不朽资料库网址
- 鲸会务智慧景区管理解决方案
猜你喜欢

中小型会议如何进行数字化升级?
![在D天内送达包裹的能力[抽象类二分--抽象判定方式]](/img/16/026c017e1c54d580fa2d237aa4605c.png)
在D天内送达包裹的能力[抽象类二分--抽象判定方式]

How to stimulate the vitality and driving force of cultural innovation
![[tcapulusdb knowledge base] Introduction to tcapulusdb push configuration](/img/98/0819d5c30a3f214d97b43f2a949fa2.png)
[tcapulusdb knowledge base] Introduction to tcapulusdb push configuration

leetcode:333. Maximum BST subtree

Solution de gestion de la zone pittoresque intelligente pour la réunion des baleines
![[MySQL] summary of common data types](/img/96/010c21f0aa7b443c130c5f55e5277a.png)
[MySQL] summary of common data types

【MySQL】錶數據的增删查改(DML)

鲸会务为智能化防疫工作赋能

【TcaplusDB知识库】TcaplusDB事务管理介绍
随机推荐
Mmcv Config class introduction
字符串 反转
[tcapulusdb knowledge base] tcapulusdb viewing process status introduction
【TcaplusDB知识库】TcaplusDB日常巡检介绍
leetcode 130. Surrounded Regions 被围绕的区域(中等)
Pytorch installation is super simple
SQL server queries are case sensitive
按位操作符和移位操作符
TcaplusDB君 · 行业新闻汇编(六)
Bitwise and shift operators
What are MySQL clustered indexes and nonclustered indexes?
【MySQL】常见数据类型总结
The system needs to scan all the files and try to identify the cover of the video
Mysql中创建4种索引的不同方式
在D天内送达包裹的能力[抽象类二分--抽象判定方式]
Ajout, suppression et modification des données du tableau [MySQL] (DML)
【Debug】could not find ref wiht poc XXX解决
《暗黑破坏神不朽》数据库资料站地址 暗黑不朽资料库网址
笔记(五)- JVM
Share some information I accumulated when I was working as a dotnet9 blog site