当前位置:网站首页>7-2 求解买股票问题
7-2 求解买股票问题
2022-06-24 19:44:00 【白—】
7-2 求解买股票问题
“逢低吸纳”是炒股的一条成功秘诀,如果你想成为一个成功的投资者,就要遵守这条秘诀。“逢低吸纳,越低越买”,这句话的意思是每次你购买股票时的股价一定要比你上次购买时的股价低。按照这个规则购买股票的次数越多越好,看看你最多能按这个规则买几次。
输入格式:
第1行为正整数N(1≤N≤5000)表示能买股票的天数;第2行以下是N个正整数,第i个正整数表示第i天的股价。
12
68 69 54 64 68 64 70 67 78 62 98 87
输出格式:
输出一行表示能够买进股票的最多天数。
4
代码:
#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
int a[n],c[n],max=-1;
for(int i=0; i<n; i++)
{
scanf("%d",&a[i]);
c[i]=1;
}
for(int i=0;i<n;i++)
{
for(int j=i-1;j>=0;j--)
{
if(a[i]<a[j]&&c[i]<=c[j]+1)
c[i]=c[j]+1;
if(c[i]>max)
max=c[i];
}
}
printf("%d",max);
}
202206222057三
边栏推荐
- Latest development of jetpack compose
- 379. 捉迷藏
- 376. machine tasks
- The dplyr package select function of R language moves the specified data column in the dataframe data to the first column (the first column) in the dataframe data column
- golang convert json string to map
- Epics record reference 2 -- epics process database concept
- Financial management [2]
- Financial management [4]
- Ningde times will increase RMB 45billion: Hillhouse subscribes RMB 3billion and Zeng Yuqun still controls 23% of the equity
- Financial management [3]
猜你喜欢

Still using simpledateformat for time formatting? Be careful of project collapse

Ningde times will increase RMB 45billion: Hillhouse subscribes RMB 3billion and Zeng Yuqun still controls 23% of the equity

【js】-【数组应用】-学习笔记

案例解析:用「度量」提升企业研发效能|ONES Talk
![[basic knowledge] ~ half adder & full adder](/img/06/7f1ede65dca527c8630285b587a4ba.png)
[basic knowledge] ~ half adder & full adder

伪原创智能改写api百度-收录良好

What good smart home brands in China support homekit?

#22Map介绍与API
![[JS] - [tree] - learning notes](/img/62/de4fa2a7c5e52c461b8be4a884a395.png)
[JS] - [tree] - learning notes

Fibonacci
随机推荐
jar中没有主清单属性
R language dplyr package group_ By function and summarize_ The at function calculates the dataframe to calculate the number of counts and the mean value of different groups (summary data by category v
慕思股份深交所上市:靠床垫和“洋老头”走红 市值224亿
257. 关押罪犯
去处电脑桌面小箭头
golang convert json string to map
OpenSSL SSL_ read: Connection was reset, errno 10054
常用正则表达式
03_ Spingboot core profile
golang map clear
二分查找数组下标
Theoretical analysis of countermeasure training: adaptive step size fast countermeasure training
Laravel scheduled task
[JS] - [array application] - learning notes
Latest development of jetpack compose
[JS] - [array, stack, queue, linked list basics] - Notes
gocolly-手册
从客户端到服务器
websocket学习
R语言使用nnet包的multinom函数构建无序多分类logistic回归模型、使用AIC函数比较两个模型的AIC值的差异(简单模型和复杂模型)