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 |
好心人帮我看看为什么总是超时,感觉已经很简洁了#include <iostream> #include <cmath> using namespace std; int main() { long N; if((cin>>N)&&(N>=1)&&(N<=10000)) { long pos[10000],sum=0,i; for(i=0;(i<N)&&(cin>>pos[i])&&(pos[i]>=0)&&(pos[i]<=1000000000);i++) for(int j=0;j<i;j++) sum+=2*fabs(pos[i]-pos[j]); if(i==N) cout<<sum<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator