HDU 1300 Pearls(DP)

很好用的离线版杭电OJ 这个版本包含了杭电水题里面的全部题目,内容丰富,可以供你在没有网络的时候观看题目,好好用哦. 立即下载

Pearls

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1860    Accepted Submission(s): 868


Problem 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.
 

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.
 

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
  
2 2 100 1 100 2 3 1 10 1 11 100 12
 

Sample Output
  
330 1344
 

Source
 

Recommend
Eddy   |   We have carefully selected several similar problems for you:   1227  1224  1160  1501  1502 
 


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>

#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define MID(x,y) ((x+y)>>1)

#define eps 1e-8
#define INF 0x3f3f3f3f

typedef __int64 ll;

using namespace std;
#define INF 0x3f3f3f3f

#define N 205

int n,num[N],p[N];
int sum[N];
int dp[N];

void DP()
{
    int i,j;
    memset(dp,INF,sizeof(dp));
    dp[0]=0;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<i;j++)
            dp[i]=min(dp[i],dp[j]+(sum[i]-sum[j]+10)*p[i]);//枚举当前状态可以由哪些状态而来
    }
    printf("%d\n",dp[n]);
}
int main()
{
    int i,j,t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        for(i=1;i<=n;i++)
        {
            scanf("%d%d",&num[i],&p[i]);
            sum[i]=sum[i-1]+num[i];
        }
        DP();
    }
    return 0;
}




PPO实战:如何用强化学习让小车爬上MountainCarContinuous-v0山顶(附完整代码) 本文提供了使用PPO算法解决MountainCarContinuous-v0环境的完整实战教程。针对该环境的连续动作空间和稀疏奖励挑战,文章详细解析了PPO智能体的网络架构、状态归一化、GAE优势估计等核心实现,并附带了可直接运行的PyTorch代码。同时分享了关键的调参技巧和实战避坑指南,帮助读者高效训练智能体完成小车爬坡任务。 阅读详情

相关推荐

FPGA从入门到精通(2) - LUT

LUT:(look up table) 查找表 今天我要讲的与FPGA CLB相关的第一节LUT。根据上一节课的课程大纲,讲CLB应该是讲SLICEL(SLICEM)。不过当我打开用户手册,看了一下SLICE的结构(图一),一眼望去,这是分分钟会劝退入门者。为了让读者更好的接受以及理解,所以我打算先讲清楚它里面的每一个基本单元(LUT, 进位链,MUX,寄存器,几乎所有的FPGA器件的SLICE都是这四大件组成,只是组合不太一样而已),然后再将他们联系在一起,和读者一步步推倒出SLICE的结构。 图1​

Jasper灬兰的博客 1万+

E - Pearls(dp)

题目描述: 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 o...

年轻过成了秃顶 333

MuJoCo与Isaac Sim的无缝对接:利用USD导出功能实现强化学习场景的跨平台迁移

本文详细介绍了如何通过USD导出功能实现MuJoCo与Isaac Sim的无缝对接,助力强化学习场景的跨平台迁移。文章解析了USD格式的核心优势,包括分层合成、物理属性继承和时间轴动画,并提供了从MJCF到USD的完整转换流程及在Isaac Sim中的高级应用技巧,帮助开发者高效迁移和优化强化学习环境。

weixin_29073241的博客 517

POJ 1260-Pearls 动态规划

<br />题目来源:http://124.205.79.250/JudgeOnline/problem?id=1260<br /> <br />解题报告:<br /> <br />一开始觉得可以用贪心算法,后来发现是不对的,比方说对如下的测试数据:<br />10 10<br />5  15<br />10 23<br />就不行了。还是要用动态规划来解<br /> <br />我设f[k]代表只买前k个,可以花的最少的钱。<br />则<br />f[k]=min( (a1+a2+...+ak+10)*

kindlucy的专栏 2282

Claude Code VSCode集成开发指南:AI编程助手完整配置

Claude Code与Visual Studio Code的深度集成为开发者提供了强大的AI编程支持。本文详细介绍Claude Code VSCode扩展的安装配置、功能特性和实际应用方法。通过完整的配置流程和代码示例,帮助开发者充分利用Claude AI的智能编程能力。文章涵盖从环境搭建到高级功能应用的完整指南,包括代码自动补全、智能重构、实时代码分析等核心功能的使用技巧,以及与现有开发工作流的整合方案。

2501_93058131的博客 5982

3D Slicer肺部CT病灶体积测量:阈值法实操全流程

在医学影像分析中,病灶体积的精准测量是肿瘤评估、疗效随访和科研统计的重要基础。传统逐层手动勾画不仅耗时,且主观差异大,而基于CT值的阈值分割技术,通过设定灰度区间自动提取目标体素,能够快速生成三维分割结果,具有高效、可重复、边界标准统一的优势,尤其适用于肺部实性结节这类与周围肺实质对比度高的病灶。理解体素与CT值的关系,掌握阈值范围的设定逻辑,并配合连通域分析、边缘修正等工程化操作,即可在3D Slicer中稳定获得可靠的体积数据。本文从技术原理出发,系统梳理了DICOM导入、窗宽窗位调节、阈值选择、三维重

weixin_29050271的博客 251

pearal.

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

nearal的博客 335

如何跑通SuperPoint+LightGlue的训练代码使用gluefactory进行训练和评估?

🏆本文收录于专栏,主要记录项目实战过程中所遇到的Bug或因后果及提供真实有效的解决方案,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家!持续更新中,up!up!up!!

**My Coding Family** 1786

HDU 1300 Pearls 斜率DP 入门

HDU 1300 Pearls 给 ccc 个种类的珍珠,每个有需要的数量以及对应的价格,购买某种类时需要额外再加十个,可以通过购买高种类的来替代低种类的。 可以得到状态转移方程: dp[i]=min⁡{dp[k]+p[i]×(s[i]−s[k]+10)},k∈[1,i−1] dp[i]=\min\{dp[k]+p[i]\times(s[i]-s[k]+10)\}, k\in [1,i-1] dp...

wineandchord 253

华为面试手撕真题【求1-n的最小公倍数】

求1-n的最小公倍数

MISAYAONE的博客 2万+

Python 3.13.7 (64-bit)安装弹窗提示:Setup failed:0x80070643 - 安装时发生严重错误...如何解决?

🏆本文收录于 《全栈Bug调优(实战版)》 专栏,该专栏专注于分享我在真实项目开发中遇到的各类疑难Bug及其深层成因,并系统提供高效、可复现的解决思路和实操方案。无论你是刚入行的新手开发者,还是拥有多年项目经验的资深工程师,本专栏都将为你提供一条系统化、高质量的问题排查与优化路径,助力你加速成长,攻克技术壁垒,迈向技术价值最大化与职业发展的更高峰🚀!

**My Coding Family** 2115

HDU-1300(基础方程DP-遍历之前所有状态)

Problem 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...

weixin_34293902的博客 180

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

hdu 1300 Pearls dp

题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1300 简单dp 两种状态  单独买 或者j ~ i 合起来买   #include&lt;bits/stdc++.h&gt; using namespace std; #define ll long long int const int INF = 0x3f3f3f3f; const in...

甦萌的博客 207

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

HDU 1300 Pearls(DP)

题意  珠宝店到珍珠批发商进货  第i种价格为p[i]的珍珠需要n个  则珍珠的结算价格为∑(n+10)*p[i]   由于没种珍珠的数量结算时都要加上10   所以有时候把便宜的珍珠换为贵的结算价格反而变少了   给你一张购买清单   珍珠价格是递增的   每种珍珠都可以替换为比它贵的  求最少总花费 简单dp  令d[i]表示前i种珍珠的最少花费  sum[i]表示第1种到第第i种的总数  

Good morning,good afternoon and good night 1204

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

[HDU 1300]Pearls[DP]

题目链接:[HDU 1300]Pearls[DP] 题意分析: 总共有C种等级的珍珠,每种需要买a[i]个,单个价格为p[i]元,如果想要买某种等级的珍珠,需要先交付10个该等级珍珠的价格才能进行购买,允许使用高等级珍珠替换需要买的低等级珍珠。问:要达到采购需求,最少需要花费多少的经费?(等级越高,单价越高:) 解题思路: 设dp[i]代表到第i种等级的珍珠,需要花费的最少费用。那么初始化

闲停 679

HDU1300 Pearls —— 斜率优化DP

题目链接:https://vjudge.net/problem/HDU-1300 Pearls Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2920Accepted Submission(s): 1464 ...

alince20008的博客 191

hdu1300 Pearls 【dp】

没有看到限制条件,品质越高的价格就越贵,导致想了一个多月都写不出来。#include<bits/stdc++.h> using namespace std; int a[1024],p[1024],dp[1024],sum[1024];int main() { int _,n; scanf("%d",&_); while(_--) { scanf("%

禅境花园 543

HDU1300 Pearls(dp)

Pearls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3375    Accepted Submission(s): 1685 Problem Description In Pearlania everybody is fo...

BBHHTT的博客 364

【DP】HDU-1300 Pearls

给出n种珠宝,每种价格不同,有一定的需求量。若要购买某种珠宝,必须先付10单位的该珠宝价格。按珠宝价格从小到大输入。可以用更高价格的珠宝来代替低价格的珠宝,但是反之不行。问最后的最小花费。

JSure的代码库 873

HDU 1300 Pearls--dp

题意:有不同等级的珍珠,价格不同,现在列出需要买的珍珠,求花的最少的钱(可以买高等级的来代替低等级的) 分析:dp[i]表示从最低等级到 i 等级花的最少的钱,dp[i]=min(dp[j]+v) v是从j+1到i全买i等级花的钱。需要三重循环。 代码: #include #include #include #define INF 1000000007 using namespace std

关于学习本身 776

HDU 1300 Pearls DP .

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1300 就是要明白 一些东西的的数量的累加肯定是连续的 比如 不可能a2累加到a4,跳过a3,而应该是a2,a3 都累加到a4 #include #include #include #include using namespace std; const int maxn=200+5; con

BRCOCOLI的博客 372

HDU 1300 Pearls (dp)

【题目链接】 http://acm.hdu.edu.cn/showproblem.php?pid=1300 题目意思 皇家要购买一些珍珠,但是珍珠品质不一样,把不同品质珍珠分为1到100个等级,买没个等级的珍珠需要的支付的钱是:(数量+10)乘上单价。而皇室当然不介意买的的珍珠比要求的高级(也就是高等级珍珠可以代替低等级珍珠)现在已知皇室需要的珍珠清单,问你所需的最低价格。 解题思...

绝丶爵的博客 211

HDU 1300 Pearls (DP)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1300 题目大意:珠宝店有100种不同质量的珍珠,质量越高价钱越高,为了促进销售,每买一种类型的珍珠,要在原来的基础上必须再买10个。这时一个CFO发现,这种条件下,有时买质量更好的反而更便宜。比如要买10元的珍珠5个,20元的珍珠100个,普通的买法需要(5+10)*10 + (100+10)*20...

weixin_30565327的博客 81

HDU - 1300 Pearls (dp)

Pearls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2666    Accepted Submission(s): 1316 Problem Description In Pearlania everyb

HHH_go_的博客 1068

hdu 1300 Pearls DP

方程很好推,n^2过的。 #include #include #include using namespace std; #define maxn 105 int a[maxn],p[maxn],sum[maxn]; int dp[maxn]; int main() { int t,n; scanf("%d",&t); while(t--) { s

793
上一篇: HDU 1074 Doing Homework(状压dp)
下一篇: HDU 5375 Gray code(DP)
左眼皮跳跳~
博客等级 码龄13年 17粉丝 400原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值