hdu1896 bjfu1268 水题
很简单的模拟,我是用的优先队列。不多说,上代码(这是bjfuoj的,hdu的要稍改一下):
/*
* Author : ben
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <functional>
#include <numeric>
#include <cctype>
using namespace std; typedef struct Stone {
int p, d;
Stone(int pp, int dd) {
p = pp;
d = dd;
}
} Stone; inline bool operator<(const Stone &s1, const Stone &s2) {
if (s1.p != s2.p) {
return s1.p > s2.p;
}
return s1.d > s2.d;
} //输入非负整数,用法int a = get_int();
int get_int() {
int res = , ch;
while (!((ch = getchar()) >= '' && ch <= '')) {
if (ch == EOF)
return -;
}
res = ch - '';
while ((ch = getchar()) >= '' && ch <= '')
res = res * + (ch - '');
return res;
} int main() {
int n, p, d, ans;
bool flag;
while ((n = get_int()) > ) {
priority_queue<Stone> pq;
for (int i = ; i < n; i++) {
p = get_int();
d = get_int();
pq.push(Stone(p, d));
}
ans = ;
flag = true;
while (!pq.empty()) {
Stone s = pq.top();
ans = s.p;
pq.pop();
if (flag) {
s.p += s.d;
pq.push(s);
}
flag = !flag;
}
printf("%d\n", ans);
}
return ;
}
hdu1896 bjfu1268 水题的更多相关文章
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
- ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)
1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 154 Solved: 112[ ...
- [poj2247] Humble Numbers (DP水题)
DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...
- gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,
1195: 相信我这是水题 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 821 Solved: 219 Description GDUT中有个风云人 ...
- BZOJ 1303 CQOI2009 中位数图 水题
1303: [CQOI2009]中位数图 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 2340 Solved: 1464[Submit][Statu ...
- 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题
B - 大还是小? Time Limit:5000MS Memory Limit:65535KB 64bit IO Format: Description 输入两个实数,判断第一个数大 ...
- ACM水题
ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...
- CF451C Predict Outcome of the Game 水题
Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...
随机推荐
- hdu1020 Encoding
http://acm.hdu.edu.cn/showproblem.php?pid=1020 过了的就是好孩子........ #include<stdio.h> #include< ...
- 【互联网那些事儿】小度 i 耳目
关于这个产品是什么,大家自行度. 这里我主要想说的,是百度关于这个产品的一点……呃,“卖萌”的介绍语言. 小度i耳目常见问题 问:为什么叫小度i耳目呢,貌似不太好记忆. 答:名字嘛都是父母起的,不过时 ...
- mysql怎样建表及mysql优化
1.符合数据库三范式 2.字段选择合适的数据类型 3.注意表之间的联系,一对多,多对多,一对一 4.拆分表,把不常用的字段单独成表. 5.建立索引,哪些字段建立索引?建立索引的原则?最左前缀原则,wh ...
- 老韩思考:一个卖豆腐的能转行IT吗? 你的卖点在哪里?
前言: 我带过的学生很多,各行各业都有,泰牛程序员招生消息放出去后,还有一个在菜市场上卖豆腐的也看我的视频教程,决定转换IT行业,我想,北大毕业的可以卖猪肉,那么卖豆腐的为什么就不能从事IT行业呢?那 ...
- 汇编debug 截图
- mapper device&lvm
http://www.ibm.com/developerworks/cn/linux/l-devmapper/ http://baike.baidu.com/view/361916.htm?fr=al ...
- LE33
MIC5207-3.3YM5 MIC5207-3.3BM5 LE33代码电源管理IC芯片全新原装 http://item.taobao.com/item.htm?spm=a230r.1.14.251. ...
- Ubuntu 12.04搭建MTK 6577 安卓开发环境
Ubuntu 12.04搭建 MTK 6577安卓开发环境 1. 下载并安装Vmware虚拟机: 2. 下载并在虚拟机上安装Ubuntu 12.04 iso 安装包:下载地址: ...
- BZOJ 2154 Crash的数字表格
题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=2154 题意: 思路: i64 mou[N]; void init(int N){ ...
- git设置对比工具
windows下设置 beyond compare 3 为 git 的对比工具. 首先需要先安装 beyond compare 3 工具,切记需要安装安装版的,不要搞绿色版的. mac下使用 Kal ...