| ||||||||||
| 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 | |||||||||
Re:应该是不用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_function1(struct node a,struct node b)
{
if(a.x >= b.x) return(1);
else return(0);
}
bool sort_function2(struct node a,struct node b)
{
if(a.d <= b.d) 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_function1);
sort(a,a+k,sort_function2);
for(i=0;i<k;i++) printf("%d ",a[i].d+1);
printf("\n");
system("pause");
return(0);
}
我不知道我没什么WA?
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator