杭电2187
来源:互联网 发布:百度阅读json文件转换 编辑:程序博客网 时间:2024/04/29 00:23
#include <iostream>#include <cstdio>#include <algorithm>using namespace std;struct node{int price,weight;}stu[1100];bool cmp(node x,node y){return x.price<y.price;}int main(){int C,n,m,i,num;double sum;scanf("%d",&C);while(C--){sum=0;scanf("%d%d",&n,&m);for(i=1;i<=m;i++){scanf("%d%d",&stu[i].price,&stu[i].weight);}sort(stu+1,stu+m+1,cmp);for(i=1;i<=m;i++){num=stu[i].price*stu[i].weight;if(n>=num){n-=num;sum+=stu[i].weight;}else {sum+=1.0*n/num*stu[i].weight;break;}}printf("%.2f\n",sum);}return 0;}
0 0
- 杭电Hd 2187
- 杭电2187
- 杭电2187
- 杭电acm--2187
- 杭电2187
- 杭电2187
- 杭电
- 杭电
- 杭电
- 杭电 1234 和 杭电 2115
- 杭电2056之Rectangles 杭电
- 杭电ACM1061Rightmost Digit
- 杭电2099 7.11
- 杭电ACM 1003
- 杭电 ACM 2016
- 杭电ACM1466
- 杭电ACM1003
- 杭电ACM1225
- 【码上杂谈】关于之前对Server上允许的最大TCP连接数理解错误的更正
- poj 2082 Terrible Sets
- 背包问题
- ZOJ-3802-Easy 2048 Again【状态压缩dp】【位运算】【好题】
- compoer安装
- 杭电2187
- 单例模式
- Leetcode-136:Single Number
- 杭电1161
- 使用svn:externals建立SVN文件(夹)链接
- erlang timer
- 树莓派3玩耍日志1——开箱、安装、开机试机
- VS2013 / MFC + FFmpeg实现录屏
- SVN回滚版本