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 ...
随机推荐
- 转一篇:文档笔记之Django QuerySet
这个放着,说不定以后作一些更深入的查询时,用得着的. http://www.rapospectre.com/blog/7/ 今天刚刚答完辩体完检就跑来更新博客了!!! 先补上第一篇: 一般情况下,我们 ...
- hdu 1002 A+B
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1002 复习一下大数 模板: #include <stdio.h> #include <s ...
- 【Linux高频命令专题(21)】df
概述 linux中df命令的功能是用来检查linux服务器的文件系统的磁盘空间占用情况.可以利用该命令来获取硬盘被占用了多少空间,目前还剩下多少空间等信息. 显示指定磁盘文件的可用空间.如果没有文件名 ...
- 【Linux高频命令专题(11)】cp
概述 cp命令用来复制文件或者目录,是Linux系统中最常用的命令之一.一般情况下,shell会设置一个别名,在命令行下复制文件时,如果目标文件已经存在,就会询问是否覆盖,不管你是否使用-i参数.但是 ...
- Sina App Engine(SAE)入门教程(8)- SaeFetchurl使用
fetchurl是什么? FetchURL是SAE为开发者提供的分布式网页抓取服务,用来同步的抓取http页面,FetchURL针对国内的网络的做了优化,内部有调度系统,尽可能保证用户快速的抓取到目标 ...
- 2014-9-17二班----8 web project
http://localhost:8080/rwkj1/indexServlet 地址请求后,,,,浏览器 地址栏没有变化 package cn.rwkj.servlet; import java ...
- VIM Taglist + ctags
Windows下 进入http://ctags.sourceforge.net/ 下载ctags 把ctags58.zip解压,随便放个地方,我放到了Home\Vim\vim72下,在ctags58文 ...
- iOS 相机和相册使用授权
1.判断用户是否有权限访问相册 授权一次后,不在提示是否授权 #import <AssetsLibrary/AssetsLibrary.h> ALAuthorizationStatus a ...
- qtp与selenium2的区别
QTP: 我觉得qtp适合的人: 对编程不是很熟悉的 厌烦了手动的功能测试,想快速进入自动化行业的 公司想快速自动化项目,并且对价格或者对盗版无所谓的 vbs脚本语言易于上手,可以培训你对代码的兴趣 ...
- Pig简单入门
pig是hadoop客户端,使用类似于SQL的面向数据流的语言pig latin,这个语言可以完成排序,过滤,求和,关联等操作,可以支持自定义函数.Pig自动把pig latin 映射为Map-Red ...