zoj 2109 FatMouse' Trade 贪心
来源:互联网 发布:淘宝联盟交流群 编辑:程序博客网 时间:2024/06/06 09:34
#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>#include<math.h>using namespace std;struct data{ double j,f,x;}a[1024];bool cmp(data a,data b){ return a.x>b.x;}int main(){ int m,n,i; double sum; while(~scanf("%d %d",&m,&n)) { if(m==-1&&n==-1) break; for(i=0;i<n;i++) { scanf("%lf%lf",&a[i].j,&a[i].f); a[i].x=a[i].j/a[i].f; } sum=0; sort(a,a+n,cmp); for(i=0;i<n;i++) { if(m>a[i].f) { sum+=a[i].j; m-=a[i].f; } else { sum+=m*a[i].x; m=0; break; } } printf("%.3f\n",sum); } return 0;}
0 0
- zoj 2109 FatMouse' Trade 贪心
- ZOJ FatMouse' Trade 贪心
- zoj 2109 || hdoj1009 FatMouse' Trade(贪心)
- ZOJ 2109 FatMouse's Trade(贪心)
- ZOJ-2109FatMouse' Trade
- ZOJ 2109 FatMouse' Trade
- zoj 2109 FatMouse' Trade
- ZOJ 2109 FatMouse' Trade
- ZOJ 2109 FatMouse' Trade
- zoj 2109 FatMouse' Trade (纯水背包问题~贪心❤)
- ZOJ 2109 FatMouse' Trade (背包 dp + 贪心)
- zoj 2109 FatMouse' Trade【水】
- zoj 2109 FatMouse' Trade简单的贪心 (注意double数组的排序问题)
- Solution of ZOJ 2109 FatMouse' Trade
- ZOJ Problem Set - 2109 FatMouse' Trade
- ZOJ Problem Set - 2109 FatMouse' Trade
- zoj 2109.FatMouse' Trade
- 【贪心】 hdu1009 FatMouse' Trade
- Learning WPF / March 15,2015 / Sunday
- 3.2 视图和模型变换
- Docker学习笔记 — Compose简介、安装与简单使用
- Qt 中Warning: Z-order assignment: " is not a valid widget
- C++编程学习52个经典网站 强力推荐
- zoj 2109 FatMouse' Trade 贪心
- 集群中几种session同步解决方案的比较
- # 工程经济学第4
- (2.2.3)Java之美[从菜鸟到高手演变]之设计模式二:结构型模式
- wsmhzy
- 安卓的各种动画资源
- html代码与xhtml代码的区别
- Python核心编程 第18章 多线程
- 如何用电脑共享wifi,解决信号不稳定