当前位置:网站首页>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>边栏推荐
- 【LeetCode】1374. 生成每种字符都是奇数个的字符串
- [安洵杯 2019]easy_web
- Translate My Wonderful | July Moli Translation Program Winners Announced
- KDD 2022 | 深度图神经网络中的特征过相关:一个新视角
- setup语法糖 defineProps defineEmits defineExpose
- 信息系统项目管理师必背核心考点(五十八)变更管理的主要角色
- 【SLAM】DM-VIO(ros版)安装和论文解读
- golang源码分析之geoip2-golang
- Solve the docker mysql can't write Chinese
- 【数据分析】:什么是数据分析?
猜你喜欢
随机推荐
LM小型可编程控制器软件(基于CoDeSys)笔记二十五:plc的数据存储区(数字量输入通道部分)
基于 outline 实现头像剪裁以及预览
golang 源码分析:juju/ratelimit
GNN教程:图神经网络基础知识!
SQL Server数据类型转换函数cast()和convert()详解
银保监会:人身险产品信披材料应由保险公司总公司统一负责管理
姑姑:给小学生出点口算题
传感器工作原理
Thread线程类基本使用(下)
Meta 与苹果的元宇宙碰撞
arm64麒麟安装paddlehub(国产化)
遇上Mysql亿级优化,怎么办
线程安全(上)
Thread线程类基本使用(上)
软件测试分类
ShardingSphere-proxy +PostgreSQL implements read-write separation (static strategy)
【数据分析】:什么是数据分析?
奥特学园ROS笔记--7(289-325节)
SQL 嵌套 N 层太长太难写怎么办?
如何解决图像分类中的类别不均衡问题?不妨试试分开学习表征和分类器









![[AnXun cup 2019] easy_web](/img/26/c04bc8b9c65ac75ddd2696b48e1661.png)