| ||||||||||
| 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 | |||||||||
帮我看看这个程序怎么通不过啊,我觉得没有问题啊在VC6.0下编译通过
#include<iostream.h>
int Case[20];
int a[1000];
int arrLength=0;
int iTime=0;
void sortArray(int N)
{
int temp;
for(int i=0;i<N;i++)
for(int j=i+1;j<N;j++)
{
if(a[i]>a[j])
{
temp=a[i];a[i]=a[j];a[j]=temp;
}
}
}
void FindSoul()
{
if(arrLength==2)
iTime+=a[1];
else if(arrLength==3)
iTime+=a[0]+a[1]+a[2];
else
{
if(a[1]*2<=(a[arrLength-2]+a[0]))
{
iTime+=a[0]+2*a[1]+a[arrLength-1];
arrLength-=2;
FindSoul();
}
else
{
iTime+=2*a[0]+a[arrLength-1]+a[arrLength-2];
arrLength-=2;
FindSoul();
}
}
}
void main()
{
int M;
cin>>M;
for(int i=0;i<M;i++)
{
int N;
cin>>N;
for(int t=0;t<N;t++)
cin>>a[t];
sortArray(N);
arrLength=N;
FindSoul();
Case[i]=iTime;
iTime=0;
}
for(int k=0;k<M;k++)
cout<<Case[k]<<endl;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator