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:Re:不知道为什么排了序不行,暴搜反而可以... Posted by:yanchao at 2007-08-23 11:15:53 #include <iostream> using namespace std; int main(){ long long a[10000],n,vol=0,i,j; cin>>n; for(i=0;i<n;i++)cin>>a[i]; for(i=0;i<n;i++) for(j=i+1;j<n;j++) if(i!=j)vol+=abs(a[i]-a[j]); cout<<vol*2; } 超时。。。 只能先排序了,楼主说的有问题~ Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator