POJ 1260 Pearls
来源:互联网 发布:2017淘宝骗保师 编辑:程序博客网 时间:2024/05/29 12:26
Pearls
Time Limit: 1000MSMemory Limit: 10000KTotal Submissions: 6670Accepted: 3248
2
100 1
100 2
3
1 10
1 11
100 12
1344
Description
In Pearlania everybody is fond of pearls. One company, called The Royal Pearl, produces a lot of jewelry with pearls in it. The Royal Pearl has its name because it delivers to the royal family of Pearlania. But it also produces bracelets and necklaces for ordinary people. Of course the quality of the pearls for these people is much lower then the quality of pearls for the royal family.In Pearlania pearls are separated into 100 different quality classes. A quality class is identified by the price for one single pearl in that quality class. This price is unique for that quality class and the price is always higher then the price for a pearl in a lower quality class.
Every month the stock manager of The Royal Pearl prepares a list with the number of pearls needed in each quality class. The pearls are bought on the local pearl market. Each quality class has its own price per pearl, but for every complete deal in a certain quality class one has to pay an extra amount of money equal to ten pearls in that class. This is to prevent tourists from buying just one pearl.
Also The Royal Pearl is suffering from the slow-down of the global economy. Therefore the company needs to be more efficient. The CFO (chief financial officer) has discovered that he can sometimes save money by buying pearls in a higher quality class than is actually needed.No customer will blame The Royal Pearl for putting better pearls in the bracelets, as long as the
prices remain the same.
For example 5 pearls are needed in the 10 Euro category and 100 pearls are needed in the 20 Euro category. That will normally cost: (5+10)*10+(100+10)*20 = 2350 Euro.Buying all 105 pearls in the 20 Euro category only costs: (5+100+10)*20 = 2300 Euro.
The problem is that it requires a lot of computing work before the CFO knows how many pearls can best be bought in a higher quality class. You are asked to help The Royal Pearl with a computer program.
Given a list with the number of pearls and the price per pearl in different quality classes, give the lowest possible price needed to buy everything on the list. Pearls can be bought in the requested,or in a higher quality class, but not in a lower one.
Every month the stock manager of The Royal Pearl prepares a list with the number of pearls needed in each quality class. The pearls are bought on the local pearl market. Each quality class has its own price per pearl, but for every complete deal in a certain quality class one has to pay an extra amount of money equal to ten pearls in that class. This is to prevent tourists from buying just one pearl.
Also The Royal Pearl is suffering from the slow-down of the global economy. Therefore the company needs to be more efficient. The CFO (chief financial officer) has discovered that he can sometimes save money by buying pearls in a higher quality class than is actually needed.No customer will blame The Royal Pearl for putting better pearls in the bracelets, as long as the
prices remain the same.
For example 5 pearls are needed in the 10 Euro category and 100 pearls are needed in the 20 Euro category. That will normally cost: (5+10)*10+(100+10)*20 = 2350 Euro.Buying all 105 pearls in the 20 Euro category only costs: (5+100+10)*20 = 2300 Euro.
The problem is that it requires a lot of computing work before the CFO knows how many pearls can best be bought in a higher quality class. You are asked to help The Royal Pearl with a computer program.
Given a list with the number of pearls and the price per pearl in different quality classes, give the lowest possible price needed to buy everything on the list. Pearls can be bought in the requested,or in a higher quality class, but not in a lower one.
Input
The first line of the input contains the number of test cases. Each test case starts with a line containing the number of categories c (1<=c<=100). Then, c lines follow, each with two numbers ai and pi. The first of these numbers is the number of pearls ai needed in a class (1 <= ai <= 1000).
The second number is the price per pearl pi in that class (1 <= pi <= 1000). The qualities of the classes (and so the prices) are given in ascending order. All numbers in the input are integers.
The second number is the price per pearl pi in that class (1 <= pi <= 1000). The qualities of the classes (and so the prices) are given in ascending order. All numbers in the input are integers.
Output
For each test case a single line containing a single number: the lowest possible price needed to buy everything on the list.
Sample Input
22
100 1
100 2
3
1 10
1 11
100 12
Sample Output
3301344
Source
Northwestern Europe 2002#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int sum[1111],dp[1111],a[1111],p[1111],t,n;
int main()
{
scanf("%d",&t);
while(t--)
{
memset(sum,0,sizeof(sum));
memset(dp,63,sizeof(dp));
dp[0]=0;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d%d",a+i,p+i);
sum=sum[i-1]+a;
}
for(int i=1;i<=n;i++)
{
for(int j=0;j<i;j++)
{
dp=min(dp,dp[j]+(sum-sum[j]+10)*p);
}
}
printf("%d\n",dp[n]);
}
return 0;
}
* This source code was highlighted by YcdoiT. ( style: Codeblocks )#include <cstdio>
#include <cstring>
using namespace std;
int sum[1111],dp[1111],a[1111],p[1111],t,n;
int main()
{
scanf("%d",&t);
while(t--)
{
memset(sum,0,sizeof(sum));
memset(dp,63,sizeof(dp));
dp[0]=0;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d%d",a+i,p+i);
sum
}
for(int i=1;i<=n;i++)
{
for(int j=0;j<i;j++)
{
dp
}
}
printf("%d\n",dp[n]);
}
return 0;
}
0 0
- poj 1260 Pearls
- POJ 1260 Pearls
- POJ 1260 Pearls DP
- Poj 1260 Pearls
- POJ 1260 Pearls
- poj 1260 pearls
- poj-1260-Pearls-dp
- POJ 1260 Pearls
- POJ 1260 Pearls
- POJ 1260 Pearls
- poj 1260 Pearls
- POJ 1260 Pearls
- POJ 1260 Pearls
- poj 1260 Pearls
- POJ - 1260 Pearls
- poj 1260:Pearls
- POJ 1260 Pearls
- POJ 1260--Pearls
- Asp.Net MVC4入门指南(10):第三方控件Studio for ASP.NET Wijmo MVC4 工具应用
- POJ 3280 Cheapest Palindrome
- POJ 1191 棋盘分割
- 2013 北京 QCon热点分享
- OpenCV学习笔记[1]初探OpenCV
- POJ 1260 Pearls
- Spread Studio中文支持图解
- 自定义取值距离的javascript random()函数
- HDOJ 3555 Bomb
- Spread for ASP.NET 7新功能使用指南
- POJ 2029 Get Many Persimmon Trees
- iOS多线程实现3种方式
- XDU 1161 - 科协的数字游戏II
- Spread for Windows Forms 7新功能使用指南
原创粉丝点击
热门IT博客
热门问题
老师的惩罚
人脸识别
我在镇武司摸鱼那些年
重生之率土为王
我在大康的咸鱼生活
盘龙之生命进化
天生仙种
凡人之先天五行
春回大明朝
姑娘不必设防,我是瞎子
小语种学校排名
小语种歌曲
高考小语种
小语种学校有哪些
小语种专科学校
新东方小语种
好学的小语种
小语种培训班
学哪个小语种比较好
小语种培训费用
学什么小语种比较好
法亚小语种
北外小语种培训
欧风小语种培训中心
学哪种小语种比较好
小语种培训中心
小语种培训班多少钱
声同小语种
小语种就业排名
自学小语种
小语种考级
上外小语种培训
小语种语言
什么小语种好学
哪个小语种好学
想学小语种
小语种推广
小语种培训机构排名
塞纳小语种
小语种包括哪些
学小语种哪里好
小语种机构
小语种建站
沪江小语种
银行 小语种
学小语种可以从事什么工作
小语种在线学习
学习什么小语种好
小语种出国
哪里可以学小语种
小语种 学校