日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

HURST 1116:选美大赛(LIS+路径输出)

發(fā)布時(shí)間:2024/4/15 编程问答 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HURST 1116:选美大赛(LIS+路径输出) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
選美大賽
Time Limit: 1000 MSMemory Limit: 65536 K
Total Submit: 1099(318 users)Total Accepted: 349(252 users)Rating:?Special Judge:?No
Description

一年一度的哈理工選美大賽開始了.來自各個(gè)院系的N個(gè)美女們都在一起排成一排,然后從左到右給他們標(biāo)號(hào)(1-N),評委叫獸開始觀摩,由于身高高低都不同, 叫獸想從中選出盡可能多的人使得他們的身高從左到右依次遞增,你能幫助叫獸嗎?

Input

?

輸入數(shù)據(jù)第一行一個(gè)數(shù)據(jù)表示美女的個(gè)數(shù)N(0<N<100)

接下來有N個(gè)數(shù)據(jù)表示1-N標(biāo)號(hào)的美女的身高,身高范圍都在0-180之內(nèi)

當(dāng)N=0時(shí)候輸入結(jié)束

?

?

?

Output

?

?

按照樣例輸出,首先The number is N:N是選出最多美女個(gè)數(shù),然后后面輸出N個(gè)數(shù),代表選出美女的標(biāo)號(hào),從左到右依次輸出.

題目保證答案唯一

?

?

?

?

Sample Input

3

2 1 2

3

1 2 3

0

Sample Output

The number is 2: 2 3

The number is 3: 1 2 3

#include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <math.h> #include <limits.h> #include <map> #include <stack> #include <queue> #include <vector> #include <set> #include <string> #define ll long long #define ms(a) memset(a,0,sizeof(a)) #define pi acos(-1.0) #define INF 0x3f3f3f3f const double E=exp(1); const int maxn=1e6+10; using namespace std; int a[maxn]; int dp[maxn]; int vis[maxn]; int DP[maxn]; int main(int argc, char const *argv[]) {ios::sync_with_stdio(false);int n;while(cin>>n&&n){ ms(dp);ms(DP);ms(vis);for(int i=0;i<n;i++)cin>>a[i];int ans=INT_MIN;int res;for(int i=0;i<n;i++){dp[i]=1;for(int j=0;j<i;j++){if(a[i]>a[j]&&dp[i]<dp[j]+1){dp[i]=dp[j]+1;vis[i]=j;}}if(dp[i]>ans){ans=dp[i];res=i;}}int ress=res;int i=0;while(1){DP[i++]=vis[ress];ress=vis[ress];if(dp[ress]==1)break;}cout<<"The number is "<<ans<<":";for(int j=i-1;j>=0;j--)cout<<" "<<DP[j]+1;cout<<" "<<res+1<<endl;} return 0; }

?

轉(zhuǎn)載于:https://www.cnblogs.com/Friends-A/p/10324404.html

總結(jié)

以上是生活随笔為你收集整理的HURST 1116:选美大赛(LIS+路径输出)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。