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 |
Re:貌似要线性的算法才可以过吧In Reply To:哪位高手麻烦帮忙看看^_^,怎么会超时呢?谢谢哦~ Posted by:acm_pku at 2007-07-23 09:47:20 > #include "stdio.h" > int main() > { > int n,i,j; > unsigned int sum=0; > scanf("%d",&n); > int *a=new int[n+1]; > int *b=new int[n+1]; > for(i=1;i<=n;i++) > scanf("%d",&a[i]); > for(i=1;i<=n;i++) > { > b[i]=0; > for(j=i+1;j<=n;j++) > if(a[i]>a[j]) > b[i]++; > else > break; > } > for(i=1;i<=n;i++) > sum=sum+b[i]; > printf("%u\n",sum); > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator