bzoj1346: [Baltic2006]Coin
Description
Input
Output
#include<cstdio>
#include<algorithm>int _(){
int x=,c=getchar();
while(c<)c=getchar();
while(c>)x=x*+c-,c=getchar();
return x;
}
struct item{
int x,d;
}v[];
bool operator<(const item&a,const item&b){
return a.x<b.x;
}
int n,k,ps[],pp=;
int main(){
n=_();k=_();
for(int i=;i<n;++i)v[i].x=_(),v[i].d=!_();
std::sort(v,v+n);
v[n].x=k;
for(int i=,a;i<n;++i)if(v[i].d){
a=v[i].x+ps[pp];
if(a<v[i+].x)ps[++pp]=a;
}
if(!pp)ps[pp]=;
printf("%d\n%d\n",pp,k-ps[pp]);
return ;
}
bzoj1346: [Baltic2006]Coin的更多相关文章
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- [LeetCode] Coin Change 硬币找零
You are given coins of different denominations and a total amount of money amount. Write a function ...
- 洛谷P2964 [USACO09NOV]硬币的游戏A Coin Game
题目描述 Farmer John's cows like to play coin games so FJ has invented with a new two-player coin game c ...
- [luogu2964][USACO09NOV][硬币的游戏A Coin Game] (博弈+动态规划)
题目描述 Farmer John's cows like to play coin games so FJ has invented with a new two-player coin game c ...
- LeetCode Coin Change
原题链接在这里:https://leetcode.com/problems/coin-change/ 题目: You are given coins of different denomination ...
- ACM Coin Test
Coin Test 时间限制:3000 ms | 内存限制:65535 KB 难度:1 描述 As is known to all,if you throw a coin up and let ...
- HDOJ 2069 Coin Change(母函数)
Coin Change Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- leetcode:Coin Change
You are given coins of different denominations and a total amount of money amount. Write a function ...
- UVa 674 Coin Change【记忆化搜索】
题意:给出1,5,10,25,50五种硬币,再给出n,问有多少种不同的方案能够凑齐n 自己写的时候写出来方案数老是更少(用的一维的) 后来搜题解发现,要用二维的来写 http://blog.csdn. ...
随机推荐
- Python 将pdf转换成txt(不处理图片)
上一篇文章中已经介绍了简单的python爬网页下载文档,但下载后的文档多为doc或pdf,对于数据处理仍然有很多限制,所以将doc/pdf转换成txt显得尤为重要.查找了很多资料,在linux下要将d ...
- ZOJ 1110 Dick and Jane
原题链接 题目大意:Dick和Jane的年龄之和等于他们宠物的年龄,宠物之间的年龄关系XXX. 解法:小学奥数题目,枚举法. 参考代码: #include<iostream> #inclu ...
- javaio-printwriter
转自http://www.cnblogs.com/skywang12345/p/io_25.html PrintWriter 介绍 PrintWriter 是字符类型的打印输出流,它继承于Writer ...
- 深入理解HTTP
深入理解HTTP协议(转) http协议学习系列 1. 基础概念篇 1.1 介绍 HTTP是Hyper Text Transfer Protocol(超文本传输协议)的缩写.它的发展是万维网协会(Wo ...
- php下载c
1.php下载中,不认识的类型比如zip,rar,rmvb等可以直接点击链接下载<a href="one.zip">one.zip</a>. 2.php下载 ...
- SysTick 定时器的使用
SysTick是STM32中的一个24位的定时器. Cortex‐M3处理器内部包含了一个简单的定时器.因为所有的CM3芯片都带有这个定时器,软件在不同 CM3器件间的移植工作得以化简.该定时器的时钟 ...
- C++@重载函数
关于重载详细分析参考: http://www.cnblogs.com/skynet/archive/2010/09/05/1818636.html 内部机制涉及重载函数如何解决命名冲突,调用匹配的问题 ...
- php mcrypt 完全安装
今天安装完 PHP ,访问某个功能时, /var/log/httpd/error_log 中报如下错误: PHP Fatal error: Call to undefined function ...
- 安全-分析深圳电信的新型HTTP劫持方式
ISP的劫持手段真是花样百出,从以前的DNS(污染)劫持到后来的共享检测,无不通过劫持正常的请求来达到他们的目的. 之前分析过通过劫持HTTP会话,插入iframe来检测用户后端有无共享行为,但后来移 ...
- Python元组的简单介绍
1.实际上元组是跟列表非常相近的另一种容器类型.元组和列表看上去的不同的一点是元组用圆括号而列表用方括号.而在功能上,元组是一种不可变的类型.正是因为这个原因,元组可以做一些列表不可以做的事情,比如用 ...