当前位置:网站首页>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>边栏推荐
猜你喜欢
模板的进阶
开关、电机、断路器、电热偶、电表接线图大全
"A daily practice, happy water problem" 1374. Generate a string with an odd number of each character
Shell: conditional statements
解析Collection接口中的常用的被实现子类重写的方法
PG's SQL execution plan
Implement fashion_minst clothing image classification
SQL Server实现group_concat功能
【软件工程导论】软件工程导论笔记
ShardingSphere-proxy +PostgreSQL实现读写分离(静态策略)
随机推荐
【LeetCode】1374. 生成每种字符都是奇数个的字符串
Implement fashion_minst clothing image classification
Flutter with internationalized adapter automatically generated
J9数字货币论:识别Web3新的稀缺性:开源开发者
Wintun:一款惊艳的 WireGuard 虚拟网卡接口驱动
广东省数字经济发展指引 1.0之建成数据安全保障体系
KDD 2022 | 深度图神经网络中的特征过相关:一个新视角
J9 digital theory: the Internet across chain bridge has what effect?
SQL Server安装教程
顺序查找和折半查找,看这篇就够了
SQL Server实现group_concat功能
Axure9的元件用法
J9 Digital Currency Theory: Identifying Web3's New Scarcity: Open Source Developers
PLC工作原理动画
特拉维夫大学 | Efficient Long-Text Understanding with Short-Text Models(使用短文本模型进行高效的长文本理解)
setup语法糖 defineProps defineEmits defineExpose
EasyExcel dynamic parsing and save table columns
.NET性能优化-你应该为集合类型设置初始大小
Helm基础知识
AI Scientist: Automatically discover hidden state variables of physical systems