2013 ACM区域赛长沙 A Alice’s Print Service HDU 4791
题意:就是一个打印分段收费政策,印的越多,单张价格越低,输入需要印刷的数量,求最小印刷费用一个细节就是,比当前还小的状态可能是最后几个。
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<iostream>
#define LL long long
#define PI atan(1.0)*4
#define DD double
#define MAX 200200
#define mod 100
#define dian 1.000000011
#define INF 0x3f3f3f
#define clc(a,b) memset(a,b,sizeof(a))
using namespace std;
const int maxn=;
LL s[maxn],p[maxn],c[maxn];
LL minn[maxn];//记录i之后最小的s*p,不包括当前i状态
int main() {
// freopen("inn.txt","r",stdin);
int T;
scanf("%d",&T);
while(T--) {
int n,m;
LL ans=;
clc(s,);
clc(p,);
clc(c,);
scanf("%d%d",&n,&m);
for(int i=; i<n; i++) {
scanf("%I64d%I64d",&s[i],&p[i]);
c[i]=s[i]*p[i];
}
LL minx=c[n-];
minn[n-]=c[n-];
for(int i=n-;i>=;i--){
if(c[i+]<minx){
minx=c[i+];
minn[i]=minx;
}
else{
minn[i]=minx;
}
}
while(m--) {
LL q;
scanf("%I64d",&q);
int pos=upper_bound(s,s+n,q)-s;
if(pos==n){
printf("%lld\n",q*p[n-]);
continue;
}
if(pos==) ;
else
pos=pos-;
LL pri=p[pos]*q;
if(pri>minn[pos])
ans=minn[pos];
else
ans=pri;
printf("%lld\n",ans);
}
}
return ;
}
2013 ACM区域赛长沙 A Alice’s Print Service HDU 4791的更多相关文章
- 2013 ACM区域赛长沙 C Collision HDU 4793
题意:在平面上0,0点,有一个半径为R的圆形区域,并且在0,0点固定着一个半径为RM(<R)的圆形障碍物,现在圆形区域外x,y,有一个半径 为r的,并且速度为vx,vy的硬币,如果硬币碰到了障碍 ...
- 2013 ACM区域赛长沙 H zoj 3733 (hdu 4798) Skycity
题意:一个圆台,底面和顶面半径分别为R,r,然后高度为H,一共F层,每层高度一样,然后要在每层的天花板上贴方格玻璃,方格玻璃要满足以下几个条件: 方格玻璃面积不能小于S,且方格玻璃要围成一个正多边形, ...
- 2013 ACM区域赛长沙 I LIKE vs CANDLE(ZOJ3734) 很好的一道树形DP
题意:一棵有根树,每个节点都有一个value值和属性(zan或是 CANDLE).你可以通过反转一些点的属性,反转一个点时候,它的整个子树都会被反转属性.有些点反转消耗代价为X,有些为Y.你的目标的是 ...
- 2013 ACM区域赛长沙 K Pocket Cube hdu 4801
题意:给了一个2*2的魔方..每步操作可以将任意一面翻转90度..现在问在N(<=7)步内.最多能翻出几面相同的. 直接打表模拟每种翻转情况 #include<cstdio> #in ...
- 2013 ACM/ICPC 长沙现场赛 A题 - Alice's Print Service (ZOJ 3726)
Alice's Print Service Time Limit: 2 Seconds Memory Limit: 65536 KB Alice is providing print ser ...
- 2013亚洲区域赛长沙站 ZOJ 3732 Graph Reconstruction
题目链接 Graph Reconstruction 题意 给你无向图每个点的度数, 问是否存在唯一解, 存在输出唯一解, 多解输出两个, 无解输出IMPOSSIBLE 思路 这里用到了 Havel-H ...
- HDU 4791 Alice's Print Service (2013长沙现场赛,二分)
Alice's Print Service Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- HDU 4791 Alice's Print Service 思路,dp 难度:2
A - Alice's Print Service Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & ...
- Alice's Print Service
Alice's Print Service Time Limit: 2 Seconds Memory Limit: 65536 KB Alice is providing print ser ...
随机推荐
- linux进程间通信--无名管道
管道 只能用于具有亲缘关系的进程之间通信是一个半双工的通信模式, 具有固定的写读端和写端,管道可以看成一种特殊的文件,对它可以使用普通的read.write等操作 管道的创建: #include &l ...
- 关于Hibernate框架的面试题
1.Hibernate的工作原理及为什么要用? 原理: 1读取并解析配置文件 2.读取并解析映射信息,创建SessionFactory 3.打开Session 4.创建事务Transation 5.持 ...
- eclipse中DDMS的LOGcat只有一列level
拷贝来源:http://www.cnblogs.com/kobe8/p/4620785.html http://stackoverflow.com/questions/25010393/eclipse ...
- c# winform 隐藏tabcontrol标签
Apperarance 属性:Faltbuttons SizeMode属性:Fixed 各个TabPage的Text :空 ItemSize : Width=0;Height=1;
- IOS多线程之NSThread
参考:http://blog.csdn.net/totogo2010/article/details/8010231 1 简介 NSThread: 优点:NSThread 比其他两个轻量级 缺点:需要 ...
- AOP和IOC理解
在百度上看到一篇很有意思的文章,是对AOP的一种解释,如下:(摘自:百度文库的 AOP和IOC最容易理解的说明(Spring知识小计)): IOC,依赖倒置的意思, 所谓依赖,从程序的角度看,就是比如 ...
- Nth Digit | leetcode
Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... Note: n i ...
- EXCEL : We can't do that to a merged cell.
- shell 基础 $(cd `dirname $0`;pwd)
$ cd `dirname $0` 和PWD%/* shell变量的一些特殊用法 在命令行状态下单纯执行 $ cd `dirname $0` 是毫无意义的.因为他返回当前路径的"." ...
- settimeout vs setinternal
http://blog.sina.com.cn/s/blog_6b1ab3be0100pzmo.html http://www.360doc.com/content/11/0412/17/100779 ...