hdu4957(贪心)
来源:互联网 发布:蛋白粉 手术后 知乎 编辑:程序博客网 时间:2024/05/29 07:26
wa了好久
/** this code is made by LinMeiChen* Problem:* Type of Problem:* Thinking:* Feeling:*/#include<iostream>#include<algorithm>#include<stdlib.h>#include<string.h>#include<stdio.h>#include<math.h>#include<string>#include<vector>#include<queue>#include<list>using namespace std;typedef long long lld;typedef unsigned int ud;#define oo 0x3f3f3f3f#define maxn 44struct Buckets{ double a, b;}but[maxn];bool cmp(Buckets b1, Buckets b2){ return b1.b*b2.a < b2.b*b1.a;}int main(){ int T, n; double v, time; bool flag; scanf("%d", &T); while (T--) { flag = false; scanf("%d%lf", &n, &v); for (int i = 1; i <= n; i++) scanf("%lf", &but[i].a); for (int i = 1; i <= n; i++) scanf("%lf", &but[i].b); for (int i = 1; i <= n; i++) if (but[i].a >= v && but[i].b != 0.0) { flag = true; break; } if (flag) { printf("-1\n"); continue; } sort(but + 1, but + 1 + n, cmp); time = 0.0; for (int i = 1; i <= n; i++) if (but[i].b != 0) time += (but[i].b + but[i].a*time) / (v - but[i].a); printf("%0.f\n", time); } return 0;}
0 0
- hdu4957(贪心)
- 贪心!
- 贪心~
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- Map中的值迭代
- 第十二周 项目一 程序阅读2-2
- Myeclipse的standard、pro、spring、Blue、Bling版本功能差别
- C语言编程100例之7
- eclipse菜单中没有 Android SDK and AVD Manager解决办法
- hdu4957(贪心)
- mac安装gradle
- 日常开发中一些工具框架技术的学习使用
- 【Spark亚太研究院系列丛书】Spark实战高手之路-第一章 构建Spark集群(第五步)(11)
- 第12天 依然休息了
- 计算刑警的射击成绩
- 『IOS』再看ios的事件处理
- 实现C标签输出html样式的内容示例
- Unity3D脚本入门数据类型和基本运算