很简单的模拟,我是用的优先队列。不多说,上代码(这是bjfuoj的,hdu的要稍改一下):

  1. /*
  2. * Author : ben
  3. */
  4. #include <cstdio>
  5. #include <cstdlib>
  6. #include <cstring>
  7. #include <cmath>
  8. #include <ctime>
  9. #include <iostream>
  10. #include <algorithm>
  11. #include <queue>
  12. #include <set>
  13. #include <map>
  14. #include <stack>
  15. #include <string>
  16. #include <vector>
  17. #include <deque>
  18. #include <list>
  19. #include <functional>
  20. #include <numeric>
  21. #include <cctype>
  22. using namespace std;
  23.  
  24. typedef struct Stone {
  25. int p, d;
  26. Stone(int pp, int dd) {
  27. p = pp;
  28. d = dd;
  29. }
  30. } Stone;
  31.  
  32. inline bool operator<(const Stone &s1, const Stone &s2) {
  33. if (s1.p != s2.p) {
  34. return s1.p > s2.p;
  35. }
  36. return s1.d > s2.d;
  37. }
  38.  
  39. //输入非负整数,用法int a = get_int();
  40. int get_int() {
  41. int res = , ch;
  42. while (!((ch = getchar()) >= '' && ch <= '')) {
  43. if (ch == EOF)
  44. return -;
  45. }
  46. res = ch - '';
  47. while ((ch = getchar()) >= '' && ch <= '')
  48. res = res * + (ch - '');
  49. return res;
  50. }
  51.  
  52. int main() {
  53. int n, p, d, ans;
  54. bool flag;
  55. while ((n = get_int()) > ) {
  56. priority_queue<Stone> pq;
  57. for (int i = ; i < n; i++) {
  58. p = get_int();
  59. d = get_int();
  60. pq.push(Stone(p, d));
  61. }
  62. ans = ;
  63. flag = true;
  64. while (!pq.empty()) {
  65. Stone s = pq.top();
  66. ans = s.p;
  67. pq.pop();
  68. if (flag) {
  69. s.p += s.d;
  70. pq.push(s);
  71. }
  72. flag = !flag;
  73. }
  74. printf("%d\n", ans);
  75. }
  76. return ;
  77. }

hdu1896 bjfu1268 水题的更多相关文章

  1. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  2. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  3. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  4. [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 ...

  5. gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,

    1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人 ...

  6. BZOJ 1303 CQOI2009 中位数图 水题

    1303: [CQOI2009]中位数图 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2340  Solved: 1464[Submit][Statu ...

  7. 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题

    B - 大还是小? Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Description 输入两个实数,判断第一个数大 ...

  8. ACM水题

    ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...

  9. CF451C Predict Outcome of the Game 水题

    Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...

随机推荐

  1. SQO2008配置管理工具服务显示远程过程调用失败

    前两天,装了VS2012后,打开SQL2008配置管理工具,发现SQL服务名称里什么也没有,只有一个提示:(如图) 卸载了一个叫"Microsoft SQL Server 2012Local ...

  2. 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 ...

  3. net中使用母版页

    .net中使用母版页的优点 母版页提供了开发人员已通过传统方式创建的功能,这些传统方式包括重复复制现有代码.文本和控件元素:使用框架集:对通用元素使用包含文件:使用 ASP.NET 用户控件等.母版页 ...

  4. 【mongoDB中级篇①】游标cursor

    简述 通俗的说,游标不是查询结果,可以理解为数据在遍历过程中的内部指针,其返回的是一个资源,或者说数据读取接口. 客户端通过对游标进行一些设置就能对查询结果进行有效地控制,如可以限制查询得到的结果数量 ...

  5. eclipse配置jdk问题

    1.JDK安装成功,eclipse也安装成功,这时候实际上是可以不配置JDK,因为系统已经默认给你配置好了,

  6. 数据挖掘10大算法(1)——PageRank

    1. 前言 这系列的文章主要讲述2006年评出的数据挖掘10大算法(见图1).文章的重点将偏向于算法的来源以及算法的主要思想,不涉及具体的实现.如果发现文中有错,希望各位指出来,一起讨论. 图1 来自 ...

  7. 关于use-default-filters的一个问题

    use-default-filters=true 默认行为会自动扫描所有注解

  8. 223. Rectangle Area

    题目: Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defin ...

  9. js判断浏览器类型 js判断ie6不执行

    js判断浏览器类型 $.browser  对象 $.browser.version 浏览器版本 var binfo = ''; if ($.browser.msie) { binfo = " ...

  10. Python错误处理

    中文注释出错,把UTF-8标明放在文件头就行了 # coding: utf-8