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 ...
随机推荐
- SQO2008配置管理工具服务显示远程过程调用失败
前两天,装了VS2012后,打开SQL2008配置管理工具,发现SQL服务名称里什么也没有,只有一个提示:(如图) 卸载了一个叫"Microsoft SQL Server 2012Local ...
- spring 与 CXF 整合 webservice 出现error “Unable to locate Spring NamespaceHandler for XML schema namespace” 总结
我试了多个版本的spring 发现 出现error : Unable to locate Spring NamespaceHandler for XML schema namespace 并非都是sp ...
- net中使用母版页
.net中使用母版页的优点 母版页提供了开发人员已通过传统方式创建的功能,这些传统方式包括重复复制现有代码.文本和控件元素:使用框架集:对通用元素使用包含文件:使用 ASP.NET 用户控件等.母版页 ...
- 【mongoDB中级篇①】游标cursor
简述 通俗的说,游标不是查询结果,可以理解为数据在遍历过程中的内部指针,其返回的是一个资源,或者说数据读取接口. 客户端通过对游标进行一些设置就能对查询结果进行有效地控制,如可以限制查询得到的结果数量 ...
- eclipse配置jdk问题
1.JDK安装成功,eclipse也安装成功,这时候实际上是可以不配置JDK,因为系统已经默认给你配置好了,
- 数据挖掘10大算法(1)——PageRank
1. 前言 这系列的文章主要讲述2006年评出的数据挖掘10大算法(见图1).文章的重点将偏向于算法的来源以及算法的主要思想,不涉及具体的实现.如果发现文中有错,希望各位指出来,一起讨论. 图1 来自 ...
- 关于use-default-filters的一个问题
use-default-filters=true 默认行为会自动扫描所有注解
- 223. Rectangle Area
题目: Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defin ...
- js判断浏览器类型 js判断ie6不执行
js判断浏览器类型 $.browser 对象 $.browser.version 浏览器版本 var binfo = ''; if ($.browser.msie) { binfo = " ...
- Python错误处理
中文注释出错,把UTF-8标明放在文件头就行了 # coding: utf-8