当前位置:网站首页>聪明的美食家 C语言
聪明的美食家 C语言
2022-07-26 08:53:00 【jeff one】
聪明的美食家 C语言
题目描述:
如果有人认为吃东西只需要嘴巴,那就错了。
都知道舌头有这么一个特性,“由简入奢易,由奢如简难”(据好事者考究,此规律也适合许多其他情况)。具体而言,如果是甜食,当你吃的食物不如前面刚吃过的东西甜,就很不爽了。
大宝是一个聪明的美食家,当然深谙此道。一次他来到某小吃一条街,准备从街的一头吃到另一头。为了吃得爽,他大费周章,得到了各种食物的“美味度”。他拒绝不爽的经历,不走回头路而且还要爽歪歪(爽的次数尽量多)。
输入:
输入描述:
两行数据。
第一行为一个整数n,表示小吃街上小吃的数量
第二行为n个整数,分别表示n种食物的“美味度”
输入样例:
10
3 18 7 14 10 12 23 41 16 24
输出:
输出描述:
一个整数,表示吃得爽的次数
输出样例:
6
提示:
HINT:时间限制:1.0s 内存限制:256.0MB
美味度为0到100的整数
n<1000
来源:
蓝桥杯练习系统 ID: 320 原题链接: http://lx.lanqiao.cn/problem.page?gpid=T320
#include <stdio.h>
int a[1010],b[1010],i,j,k;
int main()
{
int num;
scanf("%d",&num);
for(i=1;i<=num;i++)
scanf("%d",&a[i]);
for(i=1;i<=num;i++)
b[i]=1;
for(i=1;i<=num;i++)
{
for(j=1;j<i;j++)//从第一个数到i
{
if(a[i]>=a[j])
{
b[i]=b[i]>b[j]+1?b[i]:b[j]+1;
}
}
}
k=1;
for(i=num;i>=0;i--)
if(k<b[i])
{
k=b[i];
}
printf("%d",k);
return 0;
}
边栏推荐
- day06 作业--技能题2
- 公告 | FISCO BCOS v3.0-rc4发布,新增Max版,可支撑海量交易上链
- JS file import of node
- 合工大苍穹战队视觉组培训Day5——机器学习,图像识别项目
- [suggestions collection] summary of MySQL 30000 word essence - locking mechanism and performance tuning (IV) [suggestions collection]
- Hegong sky team vision training Day6 - traditional vision, image processing
- TCP solves the problem of short write
- Pan micro e-cology8 foreground SQL injection POC
- Study notes of automatic control principle -- dynamic model of feedback control system
- Rocky基础练习题-shell脚本2
猜你喜欢
【数据库 】GBase 8a MPP Cluster V95 安装和卸载
day06 作业--技能题1
QtCreator报错:You need to set an executable in the custom run configuration.
Pan micro e-cology8 foreground SQL injection POC
Database operation skills 6
Kotlin属性与字段
Media at home and abroad publicize that we should strictly grasp the content
C#入门系列(三十一) -- 运算符重载
at、crontab
Pxe原理和概念
随机推荐
mysql函数
CIS 2020 - alternative skills against cloud WAF (pyn3rd)
Database operation topic 2
Registration of finite element learning knowledge points
keepalived双机热备
Hegong sky team vision training Day6 - traditional vision, image processing
2000年的教训。web3是否=第三次工业革命?
[recommended collection] MySQL 30000 word essence summary - query and transaction (III)
PXE principles and concepts
Database operation skills 6
187. Repeated DNA sequence
P3743 Kotori's equipment
03 exception handling, state keeping, request hook -- 04 large project structure and blueprint
The largest number of statistical absolute values --- assembly language
[database] gbase 8A MPP cluster v95 installation and uninstall
Cve-2021-21975 VMware SSRF vulnerability recurrence
Set of pl/sql -2
Probability model in machine learning
In the first year of L2, the upgrade of arbitrum nitro brought a more compatible and efficient development experience
Form form