当前位置:网站首页>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>边栏推荐
猜你喜欢
随机推荐
六石管理学:入门机会只有一次,先把产品做好
The so-called fighting skill again gao also afraid of the chopper - partition, depots, table, and the merits of the distributed
美国爱荷华州立大学| Improving Distantly Supervised Relation Extraction by Natural Language Inference(通过自然语言推理改进远程监督关系提取)
【LeetCode】622. 设计循环队列
谷歌竞价机器学习如何去理解?
Redis集群配置
银保监会:人身险产品信披材料应由保险公司总公司统一负责管理
顺序查找和折半查找,看这篇就够了
TPAMI2022 | TransCL: based on the study the compression of the Transformer, more flexible and more powerful
PLC工作原理动画
The time series database has been developed for 5 years. What problem does it need to solve?
李沐动手学深度学习V2-bert预训练数据集和代码实现
软件成分分析:华为云重磅发布开源软件治理服务
LeetCode - 105. 从前序与中序遍历序列构造二叉树;023.合并K个升序链表
js如何获取浏览器缩放比例
[安洵杯 2019]easy_web
C# Monitor类
ALV概念讲解
LeetCode 622 设计循环队列[数组 队列] HERODING的LeetCode之路
ABAP grammar small review