Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:不知道为什么排了序不行,暴搜反而可以...

Posted by stfairy at 2007-11-12 22:55:11 on Problem 2231
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator