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

那我就不清楚为什么WA了?能帮我看看吗?

Posted by LoveW at 2007-04-19 20:44:55 on Problem 3111
In Reply To:应该是不用 Posted by:frkstyc at 2007-04-19 20:21:49
#include <iostream>
#include <algorithm>
using namespace std;

struct node
{
  double x;
  int d;
}a[100002];

bool sort_function(struct node a,struct node b)
{ 
  if(a.x >= b.x) return(1);
  else return(0);
}

main()
{
  int k,n,i,j,v,w;
  
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++)
  {
    scanf("%d%d",&v,&w);
    a[i].d=i;
    a[i].x=(double)v/w;
  }
  partial_sort(a,a+k,a+n,sort_function);
  for(i=0;i<k;i++) printf("%d ",a[i].d+1);
  printf("\n");

  system("pause");
  return(0);
}

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