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 |
又WA,哪位大牛帮帮忙啊#include<iostream> #include<cstdio> #include<algorithm> #define SIZE 20001 using namespace std; __int64 length[SIZE]; int main( void ) { int i; long n; __int64 sum=0; __int64 money=0; cin>>n; memset( length , 0, sizeof( length ) ); for ( i=0; i<n; i++ ) { scanf("%I64d",&length[i]); sum += length[ i ]; } sort( &length[0], &length[n-1] ); for ( i=n-1; i>=1; i-- ) { money+=sum; sum-=length[i]; } printf("%I64d\n",money); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator