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 |
郁闷,为什么不能过?TLE#include<stdio.h> long long a[500000]; long long aa; void gb(int x,int y) { if(x<y) { gb(x,(x+y)/2); gb((x+y)/2+1,y); int i=x,j=(x+y)/2+1,k,s; while((i<j)&&(j<=y)) { while((a[i]<=a[j])&&(i<j))i++; aa+=j-i; s=a[j]; for(k=j;k>i;k--)a[k]=a[k-1]; a[i]=s; i++; j++; } } } main() { int n; scanf("%d",&n); while(n) { for(int i=0;i<n;i++)scanf("%I64d",a+i); aa=0; gb(0,n-1); printf("%I64d\n",aa); scanf("%d",&n); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator