| ||||||||||
| 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 | |||||||||
雨季都过了…………依然wawa叫……怎么回事啊 !大虾帮忙找出bug数据就行!
#include<iostream.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int n,s[100003];
long long sum;
int main()
{
int i,k,t,m;
cin>>n;
for(i=1;i<=n;i++)
scanf("%d",s+i);
std::sort(s+1,s+n);
sum=0;
for(k=1;k<n;k++)
{
m=n;
t=s[2*k-1]+s[2*k];
sum=sum+t;
while(s[m+k-1]>t){s[m+k]=s[m+k-1];m--;}
s[m+k]=t;
}
printf("%I64d\n",sum);
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator