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. ...
随机推荐
- Java ArrayList的使用方法
首先ArrayList的一个简单实例: package chapter11; import java.util.ArrayList; public class TestArrayList { publ ...
- Cache
1.Cache中的块与主存储器中的块时按照什么样的规则建立对应关系的? 2.在这种对应关系下,主存地址又是如何变换成Cache地址的? Cache信息: 1.数据Cache和指令Cache是分开还是统 ...
- 二维数组的传输 (host <-> device)
前言 本文的目的很明确:介绍如何将二维数组传递进显存,以及如何将二维数组从显存传递回主机端. 实现步骤 1. 在显存中为二维数组开辟空间 2. 获取该二维数组在显存中的 pitch 值 (cudaMa ...
- Xcode编译异常和警告汇总(持续更新中)
1.Method definition for 'xxx' not found xxx的方法没有实现 出现原因.h声明了xxx方法但是.m没有实现xxx方法 解决方法:在类的.m文件实现xxx方法 ...
- soapUI 在多个测试套件 testsuite 里,多个testcase里传值如何实现
1.首先 要添加一个全局 自定义变量 Custom Properties 2.用transfer property 将取来的值 放入到变量 getToken 里 3.在另一个testc ...
- Js 操作Json
JSON是一个提供了stringify和parse方法的内置对象,前者用于将js对象转化为符合json标准的字符串,后者将符合json标准的字符串转化为js对象. parse方法相当于eval()方法 ...
- 【转载】.NET(C#): Task.Unwrap扩展方法和async Lambda
.NET(C#): Task.Unwrap扩展方法和async Lambda 目录 Task.Unwrap基本使用 Task.Factory.StartNew和Task.Run的Unwrap操作 使用 ...
- HDU 1061 Rightmost Digit --- 快速幂取模
HDU 1061 题目大意:给定数字n(1<=n<=1,000,000,000),求n^n%10的结果 解题思路:首先n可以很大,直接累积n^n再求模肯定是不可取的, 因为会超出数据范围, ...
- 顺序表及其多种实现方式 --- C/C++
所谓顺序表,即线性表的顺序存储结构.下面给出的是数据结构---线性表的定义. ADT List{ 数据对象: 线性表的数据对象的集合为{a1,a2,a3,...,an},每个元素的类型为ElemTyp ...
- Linux驱动设计—— 中断与时钟@request_irq参数详解
request_irq函数定义 /*include <linux/interrupt.h>*/ int request_irq(unsigned int irq, irq_handler_ ...