|
|
|
|
讨论 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 |
|
|
|
|
|
|