博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2019ICPCshenyang网络赛(C. Dawn-K's water)
阅读量:3959 次
发布时间:2019-05-24

本文共 1742 字,大约阅读时间需要 5 分钟。

题目:

Dawn-K recently discovered a very magical phenomenon in the supermarket of Northeastern University: The large package is not necessarily more expensive than the small package.

On this day, Dawn-K came to the supermarket to buy mineral water, he found that there are nntypes of mineral water, and he already knew the price pp and the weight cc (kg) of each type of mineral water. Now Dawn-K wants to know the least money aa he needs to buy no less than mm kilograms of mineral water and the actual weight bb of mineral water he will get. Please help him to calculate them.

Input
The input consists of multiple test cases, each test case starts with a number nn (1 \le n \le 10^31≤n≤103) – the number of types, and mm (1 \le m \le 10^41≤m≤104) – the least kilograms of water he needs to buy. For each set of test cases, the sum of nn does not exceed 5e45e4.

Then followed n lines with each line two integers pp (1 \le p \le 10^91≤p≤109) – the price of this type, and cc (1 \le c \le 10^41≤c≤104) – the weight of water this type contains.

Output
For each test case, you should output one line contains the minimum cost aa and the weight of water Dawn-K will get bb. If this minimum cost corresponds different solution, output the maximum weight he can get.

(The answer aa is between 11 and 10^9109, and the answer bb is between 11 and 10^4104)

样例输入

3 32 13 11 13 52 31 23 3

样例输出

3 33 6

题意描述:这个题可以看成是一个完全背包的问题,就是要买满足至少m的水需要花费的最少钱是多少,其中n是水的种类,a[i]是水的价格,b[i]是以a[i]的价格买的水的重量。

程序代码:

#include
#include
using namespace std;long long mi=1e14;//表示样例所给的大小是10000int a[1010],b[1010];long long dp[50100];//给的样例是10^9,所以用long longint main(){
int i,j,k,m,n,sum; long long x,y; while(scanf("%d%d",&n,&m)!=EOF) {
sum=20010; for(i=0;i

转载地址:http://dexzi.baihongyu.com/

你可能感兴趣的文章
shell中$*和$@的区别
查看>>
log4cxx 的编译安装过程和使用
查看>>
简单邮件系统程序
查看>>
STL里的multimap使用详解
查看>>
STL 库其中的 std::string用法总结
查看>>
模态对话框的销毁过程与非模态对话的几种销毁方法
查看>>
C++实现http下载 && 24点计算编码风格
查看>>
memcached了解使用和常用命令详解
查看>>
GDB调试各功能总结
查看>>
"undefined reference to" 多种可能出现的问题解决方法
查看>>
类结构定义
查看>>
Windows下关于多线程类 CSemaphore,CMutex,CCriticalSection,CEvent,信号量CSemaphore的使用介绍
查看>>
图像处理基本算法(汇总)以及实现
查看>>
C++编程获取本机网卡信息 本机IP 包括Windows和Linux
查看>>
23种设计模式详解及C++实现
查看>>
C++连接CTP接口实现简单量化交易
查看>>
服务端使用c++实现websocket协议解析及通信
查看>>
C# string.Format使用说明
查看>>
Linux下安装Mysql数据库开发环境
查看>>
Linux用户及用户组添加和删除操作
查看>>