当前位置:网站首页>* 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元素 放到合适的位置
边栏推荐
猜你喜欢
随机推荐
*2-1 OJ 254 翻煎饼
How to develop small programs?should focus on features
微信小程序getPhoneNumber接口code=40013
RHCE课程总结
Recursive implementation of the Tower of Hanoi problem
1.11 flink中的动态加载udf jar包
C语言 求一个整数存储在内存中的二进制中1的个数(多种方法详解)
响应式pbootcms模板外贸灯具类网站
*2-4 每日温度 *2-5 接雨水
shell课程总结
【ClickHouse】 日志清理方法(query_log、query_thread_log)
阿里巴巴开源大规模稀疏模型训练/预测引擎DeepRec
[Video coding learning] - understanding of transformation
源码编译安装LAMP
【视频编码学习】——SAD和SATD
Mysql seven connection query methods
手机厂商失守元宇宙
LNMP架构搭建之论坛
Firewalld防火墙基础
C语言 交换两个变量(不创建临时变量) 代码详解








