According to the question, the length is small and the frequency is low, so K = L/Q is set;
Then, sort the sort.
| 14128675 |
1346 |
Songs |
Accepted |
C ++ |
0.029 |
11:30:14 |
#include <iostream>#include <cstdlib>#include <cstdio>#include <string>#include <cstring>#include <cmath>#include <vector>#include <queue>#include <stack>#include <algorithm>using namespace std;const double eps = 1e-10;#define MAXD 100000 + 10#define _PI acos(-1.0)struct Pow{ double k; int n; double L; double Hz; friend bool operator <(Pow p,Pow q){ return p.k < q.k; }}value[MAXD];int main(){ int n; while(scanf("%d",&n) != EOF){ for(int i = 0 ; i < n ; i++){ scanf("%d%lf%lf",&value[i].n,&value[i].L,&value[i].Hz); value[i].k = 1.0 * value[i].L / value[i].Hz; } sort(value,value + n); int t; scanf("%d",&t); printf("%d\n",value[t - 1].n); } return 0;}
[Ultraviolet A] 1346-songs (Greedy)