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 |
WA的代码……In Reply To:按长度dp而已…WHY WA????…WA的我要哭…… Posted by:JokerKS at 2010-10-04 15:02:10 #include<stdio.h> int n,dp[1100000],dps[1100000],s[1100000],k; void work() { int i,j,p,q,m; for(j=2;j<=k;j*=2) for(i=1,p=j;p<=n;i++,p++) { if(dp[p]>dp[i]) dp[i]=dp[p]; if(dps[p]<dps[i])dps[i]=dps[p]; } j/=2; for(i=1,p=k-j+1,m=n-k+1;i<=m;i++,p++) printf("%d ",dps[i]<dps[p]?dps[i]:dps[p]); printf("\n"); for(i=1,p=k-j+1,m=n-k+1;i<=m;i++,p++) printf("%d ",dp[i] > dp[p]? dp[i]: dp[p]); printf("\n"); } int main() { int i,j; scanf("%d %d",&n,&k); if(k==1) { for(i=1;i<n;i++) { scanf("%d",&s[i]); printf("%d ",s[i]); } scanf("%d",&s[n]); printf("%d\n",s[n]); for(i=1;i<n;i++)printf("%d ",s[i]); printf("%d\n",s[n]); return 0; } for(i=1;i<=n;i++) { scanf("%d",&s[i]); dp[i]=dps[i]=s[i]; } work(); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator