标签:
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1257
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 6 const int INF = 0x3f3f3f3f; 7 int dp[1000]; 8 9 int main(){ 10 int n; 11 ios::sync_with_stdio( false ); 12 13 while( cin >> n ){ 14 int ans = 0, temp; 15 16 while( n-- ){ 17 cin >> temp; 18 int mini, min = INF, flag = 0; 19 20 for( int i = 0; i < ans; i++ ){ 21 if( temp < dp[i] && dp[i] - temp < min ){ 22 min = dp[i] - temp; 23 mini = i; 24 flag = 1; 25 } 26 } 27 28 if( flag ) dp[mini] = temp; 29 else{ 30 dp[ans] = temp; 31 ans ++; 32 } 33 } 34 35 cout << ans << endl; 36 } 37 38 return 0; 39 }
标签:
原文地址:http://www.cnblogs.com/hollowstory/p/5351928.html