当前位置:网站首页>* 2-2 OJ 1163 missile interception of beta
* 2-2 OJ 1163 missile interception of beta
2022-08-09 14:50:00 【Ye Xiaobai】
题目描述

输入

输出

样例输入

样例输出

源代码
#include<stdio.h>
int n,a[1000];
int b[1000];
int top;
int find(int x)
{
int l=0,r=top;
int mid;
while(r>=l)
{
mid=(l+r)/2;
if(x>=b[mid])
{
l=mid+1;
}
else r=mid-1;
}
return l;
}
int main()
{
while(~scanf("%d",&n))
{
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
top=0;
b[0]=a[n-1];
for(int i=n-2;i>=0;i--)
{
if(a[i]>=b[top])
{
b[++top]=a[i];
}
else b[find(a[i])]=a[i];
}
printf("%d\r\n",top+1);
}
return 0;
}
关于这题
This question actually asks for it form a monotonically decreasing sequence 中 How many can there be at most
(So some missiles can not be intercepted The goal is to find the optimal solution)
例如:389 207 155 300 299 1 10 65 结果为4
设立a b 两个数组
aThe array starts with the second-to-last number Then the third to last and fourth to last…
bThe first element of the array is a数组的最后一个数
如果a比b 大 Put this number inb数组下标加一 的位置
如果a比b 小 排序barray not0元素 放到合适的位置
边栏推荐
猜你喜欢
随机推荐
“未来10年,中国APP不可能回印度了”
Jetpack Compose - remember, mutableStateOf, rememberSaveable
汇编语言学习(二)
【ClickHouse】 日志清理方法(query_log、query_thread_log)
RHCE课程总结
Counter of openharmony container components
12. cuBLAS Development Guide Chinese version--Level-1 functions asum() and axpy() in cuBLAS
现实版商战:“武功再高,也怕菜刀”
Flex for openharmony container components
RHCE Course Summary
typeorm 批量插入数据优化和插入冲突操作
Recursive implementation of the Tower of Hanoi problem
*4-2 CCF 2014-12-2 Z字形扫描
在Word中如何调整编号和文字之间的间距?
汇编语言学习(十)常用指令总结
大规模并行分布式深度学习
apt-cache command
RHCE课程总结
Analysis of SEATA Distributed Transaction Framework
*2-3 OJ 1164 导弹拦截之升级版








