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. ...
随机推荐
- C# Form 非法字符
头部加上 EnableEventValidation="false" ValidateRequest="false"
- Sobel算子 (转)
幻灯片1 Sobel算子 幻灯片2 一.Sobel边缘检测算子 l 在讨论边缘算子之前,首先给出一些术语的定义: l (1)边缘:灰度或结构等信息的突变处,边缘是一个区域的结束,也是另一个区域的开始, ...
- Welcome to MacJournal!
Welcome to MacJournal 6 To get started, create a new entry by clicking on "New Entry" in t ...
- webrtc编译之libcommonaudio
[170/1600] CXX obj/webrtc/common_audio/common_audio.audio_util.o[171/1600] CXX obj/webrtc/common_aud ...
- php部分--数组(包含指针思想遍历数组);
1.创建并输出数组 (1)相同数据类型的数组$attr=array(1,2,3,4,5); print_r($attr); echo "<br>"; $sttr1=ar ...
- UVa 489 刽子手游戏
游戏规则,计算机想一个单词让你猜,你每次可以猜一个字母,如果单词里有那个字母,所有该字母都会显示出来,如果没有那个字母则计算机会在一副"刽子手"画上填一笔,这幅画一共需要7笔就能完 ...
- <初级程序员> git 的初级使用
作为程序员,Git 是一个很好的代码管理工具.Git 是一个版本控制系统,主要的作用就是记录代码的修改过程,有效的追踪文件的变化.当代码出现错误的时候可以很容易的恢复到之前的状态,不管对于个人开发还是 ...
- gdb Debugging Full Example
http://www.brendangregg.com/blog/2016-08-09/gdb-example-ncurses.html
- UserDefault的使用,保存小数据到本地-iOS
//保持到本地数据 NSArray *array=@[@"234",@"sdfe"]; NSUserDefaults *userDefault=[NSUserD ...
- C# 中DataTable转成模型List
C# 中DataTable转成模型List 引入using System.Reflection; 命名空间 使用注意实体类的属性名必须和DataTable的列名一致 使用: DBList<Sto ...