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
北京大学暑期课《ACM/ICPC竞赛训练》面向全球招生!

Re:richardhuang大哥,你是怎么通过的。哪里要注意,谢谢。

Posted by richardhuang at 2004-07-29 00:06:18 on Problem 1700
In Reply To:richardhuang大哥,你是怎么通过的。哪里要注意,谢谢。 Posted by:mmjj at 2004-07-28 23:23:26
> 我的程序还是WA:
> #include <stdio.h>
贪心时有两种情况
> main()
> {
> 
> 
> int t,tt,n,i,j;
> int a[1000];
> int min,mi,tmp;
> long time;
> 
> scanf("%d",&tt);
> 
> 
> for(t=0;t<tt;t++)
> {
> 
> scanf("%d",&n);
> 
> for(i=0;i<n;i++)
> {
> scanf("%d",&a[i]);
> }
> 
> 
> 
> for(i=0;i<n;i++)
> {
> min=1000;
> for(j=i;j<n;j++)
> if(a[j]<min) {min=a[j]; mi=j;}
> 
> 
> tmp=a[i];
> a[i]=a[mi];
> a[mi]=tmp;
> 
> }
> 
> 
> 
> 
> time=0;
> if(n==1) time=a[0];
> else
> {
> for(i=n-1;i>2;i=i-2)
> time=time+a[i];
> time=time+((int)(n/2)-1)*(a[1]*2+a[0]);
> 
> 
> if(n%2==1) time=time+a[2]+a[0]+a[1];
> else time=time+a[1];
> }
> 
> 
> printf("%ld\n",time);
> 
> 
> }
> 
> 
> 
> 
> }

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