UVA
来源:互联网 发布:java三大框架做什么的 编辑:程序博客网 时间:2024/06/03 06:10
要说的就是题意,给定的公式中 s[ i ] 看做 下标 i 就好,
再要说的就是分析下公式就能知道满足要求的方法是: 时间长度 L 短的, 频率 F 高的 往前放,也就是 L / F 越小越往前放,排序检索就好了
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <set>#include <stack>#include <queue>#include <ctype.h>#include <vector>#include <algorithm>#include <time.h>// cout << " === " << endl;using namespace std;typedef long long ll;const int maxn = 10000 + 7, INF = 0x3f3f3f3f, mod = 1e9+7;int n, i;struct song { int id, l; double f;}a[maxn];bool cmp(song a, song b) { return a.l*b.f < a.f*b.l;}int main() { while(scanf("%d", &n) != EOF && n) { for(int i = 0; i < n; ++i) scanf("%d %d %lf", &a[i].id, &a[i].l, &a[i].f); sort(a, a+n, cmp); scanf("%d", &i); printf("%d\n", a[i-1].id); } return 0;}
阅读全文
1 0
- uva
- UVA
- UVA
- UVA
- uva
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- 【POJ 1094】 Sorting It All Out (拓扑排序)
- Noip2015 Day1 T1 神奇的幻方
- JAVAWeb中请求Request,Response,cookie的中文乱码处理
- hibernate中对象的3种状态----瞬时态、持久态、脱管态
- B数与B+数
- UVA
- 245芯片说明
- java中有哪些框架
- Java大整数遇到的问题
- android egl10和egl14
- Truck History(Prim 最小生成树)
- Repeater控件的使用
- 遍历List中的Map集合
- Android 入门篇