| ||||||||||
| 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 | |||||||||
实在没有辙了,为什么总是time limit exceed!!!!!!!!!!!!!!!!!!#include<stdio.h>
#include<math.h>
#define Max 10000
void sort(__int64 b[],int n)
{
int i,j;
__int64 sum=0,temp;
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(i==j)continue;
else
{
if(b[i]-b[j]>0)
{
temp=b[i]-b[j];
}
else
{
temp=b[j]-b[i];
}
sum=sum+temp;
}
}
}
printf("%I64d\n",sum*2);
}
main()
{
int total,i;
__int64 a[Max];
if(scanf("%d",&total)==1)
{
if(total>0&&total<=10000)
{
for(i=0;i<total;i++)
{
scanf("%I64d",&a[i]);
}
sort(a,total);
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator