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 ...
随机推荐
- CCPC网络赛,HDU_5842 Lweb and String
Problem Description Lweb has a string $S$. Oneday, he decided to transform this string to a new sequ ...
- (转)所有iOS设备的屏幕分辨率
Phone: iPhone 1G 320x480 iPhone 3G 320x480 iPhone 3GS 320x480 iPhone 640x960 iPhone 4S 640x960 iPhon ...
- PHP问题
/usr/bin/ld: cannot find -lltdlcollect2: ld returned 1 exit statusmake: *** [libphp5.la] 错误 1 缺少libt ...
- 关于angular 自定义directive
关于angular 自定义directive的小结 首先我们创建一个名为"expander"的自定义directive指令: angular.module("myApp& ...
- 基于ActiveMQ的点对点收发消息
ActiveMQ是apache的一个开源消息引擎.可以作为即通引擎或者消息中间件引擎. 准备 下载ActiveMQ http://activemq.apache.org/download.html 进 ...
- php分页笔记
在做留言板的时候,用到了分页,所以写了这个分页笔记 既然已经开始写分页了,肯定掌握了了php的一些知识以及mysql的基本操作 在做分页的时候,我也遇到了很多问题,但是大家不要怕,无论什么问题 ...
- Leetcode 解题 Add Two Numbers Python
原题: You are given two linked lists representing two non-negative numbers. The digits are stored in r ...
- C语言-06复杂数据类型-03指针
指针变量的定义 变量类型 *变量名; #include <stdio.h> int main() { // 指针就一个作用:能够根据一个地址值,访问对应的存储空间 // 指针变量p前面的i ...
- gcc -D选项
一.概念 gcc的-D选项可以定义宏,这是什么意思呢? C语言源程序中有#define定义的宏,可以起到替换.条件编译的功能:定义宏的方式是放在头文件或者C文件中.gcc提供了另外一种宏定义的方法,当 ...
- iOS分类中通过runtime添加动态属性
这个的话并不是说 可以 在程序运行的时候 来几个 未知的东西 就添加什么 1 2 3 4 5的属性.而是可以在系统原有类的基础上 给那个类 集合实际的工程来添加你方便实用的东西.比如 ...