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<stdio.h> #include<string.h> #include<algorithm> using namespace std; const int eps=1e-9; double a[2010],g[2010]; int d[2010],dd[2010]; int main() { int n; while(~scanf("%d",&n)) { for(int i=1;i<=n;i++) { scanf("%lf",&a[i]); } for(int i=1;i<=n+1;i++) { g[i]=1e9; } for(int i=1;i<=n;i++) { double w=a[i]; int k=lower_bound(g+1,g+1+n,w-eps)-g; d[i]=k; g[k]=w; } for(int i=1;i<=n+1;i++) { g[i]=1e9; } for(int i=n;i>=1;i--) { double w=a[i]; int s=lower_bound(g+1,g+n+1,w-eps)-g; dd[i]=s; g[s]=w; } int maxx=0; for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) { if(dd[j]+d[i]>maxx) { maxx=d[i]+dd[j]; } } printf("%d\n",n-maxx); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator