题意:已知每首歌的标号,长度和播放频率,求一种播放顺序,使得最小,并且输出该播放顺序下第t首歌的标号。

分析:

1、长度越短,播放频率越大的歌排在前面,上式越小。

2、s(i)表示的是当前播放顺序下这首歌是第几个播放。

#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 - b) < 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 int 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;
const 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;
}

最新文章

  1. JAVA 冒泡算法
  2. 转载~kxcfzyk:Linux C语言多线程库Pthread中条件变量的的正确用法逐步详解
  3. swift项目中使用OC/C的方法
  4. jsoup html采集器
  5. 红帽Linux 配置VNC桌面远程工具
  6. LA 4255 Guess
  7. JavaScript DOM高级程序设计 7.向应用程序加入Ajax--我要坚持到底!
  8. huhamhire-hosts必备神器!
  9. 这几天阅读的shadowgun的几个shader
  10. Eclipse Useful Plugins Links
  11. 我的第一次windows规划
  12. ubuntu下pip install mysql-python 失败的解决方案
  13. iOS开发之数据存储之Preference(偏好设置)
  14. Linux系统挂载NTFS文件系统
  15. 微信小程序支付接入注意点
  16. Mac 终端 显示隐藏文件
  17. MySQL练习题2
  18. react-native-pushy 热更新
  19. content-box与border-box区别
  20. 拍案惊奇!9款神奇的jQuery/CSS3经典插件

热门文章

  1. 【PAT甲级】1009 Product of Polynomials (25 分)
  2. MySQL : INSERT INTO SELECT
  3. Ubuntu 解决TXT文本乱码问题
  4. 最新获取SkyDrive音乐外链mp3地址方法20131003
  5. python对文件中光标的操作迭代器
  6. BUU re xor
  7. java Vector的特点与使用
  8. 搭建solr集群的时候出现 ./zkcli.sh:行13: unzip: 未找到命令
  9. 如何知道某个ACTIVITY是否在前台?
  10. stm32_f103使用gcc编译的环境下printf打印函数的实现