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. ...
随机推荐
-
AE二次开发技巧之撤销、重做
原文地址:http://www.cnblogs.com/wylaok/articles/2363208.html 可以把AE自带的重做.撤销按钮或工具添加到axToolBarControl上,再把ax ...
-
Delphi线程同步
总结一下Windows常用的几种线程同步技术. 1.Critical Sections(临界段),源代码中如果有不能由两个或两个以上线程同时执行的部分,可以用临界段来使这部分的代码执行串行化.它只能在 ...
-
MAC OSX 进程间通信
Mac OS在下面IPC方式很多类型,大约如下. 1. Mach API 2. CFMessagePort 3. Distributed Objects (DO) NSDistributedNot ...
-
asp.net core mvc剖析:路由
在mvc框架中,任何一个动作请求都会被映射到具体控制器中的方法上,那框架是如何完成这样一个过程的,现在我们就来简单分析下流程. 我们紧跟上面的主题,任何一个请求都会交给处理管道进行处理,那mvc处理的 ...
-
[Mysql]——通过例子理解事务的4种隔离级别(转)
SQL标准定义了4种隔离级别,包括了一些具体规则,用来限定事务内外的哪些改变是可见的,哪些是不可见的. 低级别的隔离级一般支持更高的并发处理,并拥有更低的系统开销. 一.事务隔离级别分类 第1级别:R ...
-
linux新手记录;可执行文件直接运行
下载meshlab $sudo apt-get install meshlab 查看meshlab位置 $ whereis meshlab\meshlab: /usr/bin/meshlab /usr ...
-
Python 判断文件是否存在
参考:https://www.cnblogs.com/jhao/p/7243043.html
-
Android精通教程V
前言 大家好,给大家带来Android精通教程V的概述,希望你们喜欢 前言 如果你想学习Android开发,那你就要了解Java编程,这是基础,也是重点,如果没学Java语法就先学习,再来学Andro ...
-
maven使用及创建项目
一:简单介绍 他是一个帮我们管理jar,并帮助我们处理jar包依赖. 他是一个我们编译.测试.运行.打包的一键构建. 我们在使用后面的命令的同时,前面的过程也自动执行. 二.仓库的分类: 分本地仓库. ...
-
java上传excel文件及解析
java上传excel文件及解析 CreateTime--2018年3月5日16:25:14 Author:Marydon 一.准备工作 1.1 文件上传插件:swfupload: 1.2 文件上 ...