点击这里更换您喜欢的皮肤wtboj 首页
请点击这里登入noios   首页 入门 c++讲义 入门教程视频 金牌教程 入门视频 站务 公告 | 题库 记录 竞测 测试 闯关 作业 排名 团队 讨论 | 换肤 | 登入 注册  
News >>   新增功能:各团队管理员可以发布本团队作业了 ()

From sina007
导弹拦截
讨论 Discussion
 
G
#include<iostream>
const int N=10010;
using namespace std;
int dp[N];  //dp[i]每一个位置的最大拦截数量
struct shell{

int height;
int shifou;

}man[N];

int main(){
freopen("p1303.in","r",stdin);
freopen("p1303.out","w",stdout);
int m,n,cur;
cin>>m;
for(int i=1;i<=m;i++)
{
cin>>man[i].height;
man[i].shifou=0;
}
int maxmn=1;
int len=0;
for(int i=1;i<=m;i++){
for(int j=1;j<i;j++){
if(man[j].height>=man[i].height){
dp[i]=max(dp[i],dp[j]+1);//寻找最长下降子序列
}
 maxmn=max(maxmn,dp[i]);
}
if(man[i].shifou==1)continue;
   cur=man[i].height;
len++;
for(int t=i+1;t<=m;t++){
if(man[t].height<=cur){
cur=man[t].height;
man[t].shifou=1;
}
}

}
cout<<maxmn<<endl<<len;
fclose(stdin);
fclose(stdout);
return 0;
}
( )

此主题无回复显示
发布讨论主题 回复讨论主题
Flag
  
题号
  P1303
  其它
通过
  9人
提交
  28次
通过率
  32%
难度
  3
提交 讨论 题解
 Copyright wtboj © 2005-2006. www.wutuobang.date Powered by wtboj 关于 联系 帮助
 wtboj Information ---- Total Users : 1363 | Online Users / Processes : 0 / 40 | Processed Time : 398 ms | Server Time : 2025/12/18 12:41:28