Test instructions: The label, length, and frequency of each song are known, and the order of the play is obtained, which makes the minimum and output the label of the first song in the playing order.
Analysis:
1, the shorter the length, the greater the frequency of the song row in front, the smaller the style.
2, S (i) is the current playing order of the song is the first few plays.
#include <cstdio> #include <cstring> #include <cstdlib> #include <cctype> #include <cmath > #include <iostream> #include <sstream> #include <iterator> #include <algorithm> #include <string> #include <vector> #include <set> #include <map> #include <stack> #include < deque> #include <queue> #include <list> #define LOWBIT (x) (X & (x)) const DOUBLE EPS = 1e-8;inline int DCMP (double A, double b) {if (Fabs (a) < EPS) return 0; Return a > B? 1:-1;} typedef long Long Ll;typedef unsigned long long ull;const int int_inf = 0x3f3f3f3f;const int int_m_inf = 0x7f7f7f7f;const ll ll_inf = 0x3f3f3f3f3f3f3f3f;const LL ll_m_inf = 0x7f7f7f7f7f7f7f7f;const int dr[] = {0, 0,-1, 1,-1,-1, 1, 1};const I NT Dc[] = {-1, 1, 0, 0,-1, 1,-1, 1};const int MOD = 1e9 + 7;const Double pi = ACOs ( -1.0); const int MAXN = 70000 + 10;con St int MAXT = 10000 + 10;using namespace std;struct node{int id, Len; Double F; Double k; void Read () {scanf ("%d%d%lf", &id, &len, &f); K = len/f; } BOOL operator < (const NODE&RHS) const{return K < RHS.K; }}num[maxn];int Main () {int n; while (scanf ("%d", &n) = = 1) {for (int i = 1; I <= n; ++i) {num[i].read (); } sort (num + 1, num + 1 + N); int t; scanf ("%d", &t); printf ("%d\n", num[t].id); } return 0;}
UVA-1346 Songs (greedy + sort)