| ||||||||||
| 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<p>
#include <iostream>
using namespace std;
int main1()
{
short n,i,j;
unsigned temp;
cin>>n;
long long sum=0;
unsigned* data=new unsigned[n];
for(i=0;i<n;i++)
cin>>data[i];
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
if(data[j]>=data[i])
temp=(data[j]-data[i]);
else
temp=(data[i]-data[j]);
sum+=temp;
}
}
cout <<sum*2 <<endl;
return 0;
}
</p>
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator