Poj Solution 2675

http://poj.org/problem?id=2675

#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <math.h>
const double eps = 1e-6;
using namespace std;
double v[70000];
int id[70000], s[70000], l[70000];
bool cmp( int a, int b )
{
    return v[a]*l[b] < v[b]*l[a];
}
int main( )
{
    int i, n, a;
    while( scanf( "%d", &n ) == 1 )
    {
        for( i=0; i<n; i++ )
        {
            scanf( "%d%d%lf", id+i, l+i, v+i ); 
            s[i] = i;
        }
        sort( s, s+n, cmp );
        scanf( "%d", &a );
        printf( "%dn", id[ s[n-a] ] );
    }
    return 0;
}


											
This entry was posted in poj. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *