Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
代码备忘#include <iostream> #include <memory.h> using namespace std; int main() { int firstround[1001]; int secondround[1001]; float heights[1001]; int totalnum; cin>>totalnum; int i,j; for(i=1;i<=totalnum;i++) { cin>>heights[i]; firstround[i]=1; secondround[i]=1; } for(i=2;i<=totalnum;i++) { for(j=i-1;j>=1;j--) { if(heights[i]>heights[j]&&firstround[i]<firstround[j]+1) firstround[i]=firstround[j]+1; } } for(i=totalnum-1;i>=1;i--) { for(j=i+1;j<=totalnum;j++) { if(heights[i]>heights[j]&&secondround[i]<secondround[j]+1) secondround[i]=secondround[j]+1; } } int max=1; for(i=1;i<=totalnum;i++) { if(firstround[i]+secondround[i]>max) { max=firstround[i]+secondround[i]; for(int k=i+1;k<=totalnum;k++) { if(heights[k]==heights[i]&&secondround[k]==secondround[i]) { max++; } } } } cout<<totalnum-max+1; // system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator