当前位置:网站首页>Informatics Olympiad All-in-One (1260: [Example 9.4] Intercepting Missiles (Noip1999))
Informatics Olympiad All-in-One (1260: [Example 9.4] Intercepting Missiles (Noip1999))
2022-08-02 23:32:00 【The oranges teacher】
1260: [Example 9.4] Intercept missile (Noip1999)
Time Limit: 1000 ms Memory Limit: 65536 KB
Commits: 15078 Passes: 5806
【Title Description】
A country has developed a missile interception system in order to defend against enemy missile attacks.But this missile interception system has a flaw: Although its first shell can reach any height, each subsequent shell cannot be higher than the previous one.One day, the radar picked up an incoming missile from an enemy country.Since the system is still in the trial phase, there is only one system, so it may not be able to intercept all missiles.
Enter the altitude of the missiles flying in sequence (the altitude data given by the radar is a positive integer not greater than 30,000, and the number of missiles is not more than 1,000), calculate this systemHow many missiles can be intercepted at most, and how many sets of such missile interception systems are required to intercept all missiles.
[Enter]
Enter the altitude at which the missiles will fly in sequence.
【Output】
The first line: the maximum number of missiles that can be intercepted;
Line 2: The minimum number of systems required to intercept all missiles.
【Sample input】
389 207 155 300 299 170 158 65【Example of output】
62【Analysis】
The first question is the longest non-rising subsequence.Let a[x] denote the xth element in the original sequence, and b[x] denote the length of the non-descending subsequence of length x.When processing a[x], look up the maximum length of non-descending subsequences it can be concatenated to (i.e. compare with part b[x]).Assuming that it can be connected to a non-descending subsequence with a maximum length of maxn, then b[x]=maxn+1.The maximum value that the b array is assigned to is the answer to the first question.
The second question is the longest non-descending subsequence problem.
【Reference Code】
#include #define N 1010int dp1[N]; //The first question, the longest non-rising subsequenceint dp2[N]; //Second question, the longest sequence that does not fallint f[N]; //missile sequenceint max(int x,int y){return x > y ? x : y;}int main(){int idx=0,ans=0,cnt=0;int i,j;while(scanf("%d", &f[idx])!=EOF) //Automatic end when end of file is encountered Ctrl+Eidx++;for(i=0;i a>边栏推荐
猜你喜欢
随机推荐
4 kmiles join YiSheng group, with more strong ability of digital business, accelerate China's cross-border electricity full domain full growth
【SLAM】DM-VIO(ros版)安装和论文解读
SQL Server数据类型转换函数cast()和convert()详解
力扣每日一题-第46天-344. 反转字符串
Parse the commonly used methods in the List interface that are overridden by subclasses
Flutter with internationalized adapter automatically generated
【LeetCode】1374. 生成每种字符都是奇数个的字符串
第一次进入前20名
TPAMI2022 | TransCL: based on the study the compression of the Transformer, more flexible and more powerful
信息学奥赛一本通(1260:【例9.4】拦截导弹(Noip1999))
SQL Server实现group_concat功能
C# Barrier类
框架设计:PC 端单页多页框架如何设计与落地
ShardingSphere-proxy +PostgreSQL实现读写分离(静态策略)
ABAP语法小复习
腾讯云孟凡杰:我所经历的云原生降本增效最佳实践案例
磁盘分区的知识
SCANIA SCANIA OTL tag is introduced
五大维度解读软件测试分类
Wintun:一款惊艳的 WireGuard 虚拟网卡接口驱动








