HDU 1896 Stones
来源:互联网 发布:最近淘宝网怎么了 编辑:程序博客网 时间:2024/06/05 00:08
题意:sempr走在路上会遇见一些石头,如果遇见第奇数个石子,则将它扔到前面,如果是偶数,则什么也不做,如果某一个位置上有多个石头,则先遇见扔的比较近的那个,现在给出一些石头的初始位置和能够扔的距离,问到最后最远处的石头离初始位置多远!
#include "stack"#include "cstdio"#include "iostream"#include "cmath"#include "set"#include "sstream"#include "cctype"#include "string"#include "cstring"#include "algorithm"#include "queue"#include "map"using namespace std;#define LL long long#define inf 0x7ffffff#define pa pair<int,int>#define pi 3.1415926535897932384626433832795028841971const int M=55;struct node{ int p; int d; bool operator<(const node t) const { if(p!=t.p) return p>t.p; else return d>t.d; }};int main(){ int t,n,i,k; node temp; priority_queue<node> que; scanf("%d",&t); while(t--) { scanf("%d",&n); while(!que.empty()) que.pop(); for(i=0;i<n;i++) { scanf("%d%d",&temp.p,&temp.d); que.push(temp); } k=1; while(!que.empty()) { temp=que.top(); que.pop(); if(k&1) { temp.p+=temp.d; que.push(temp); } k++; } printf("%d\n",temp.p); } return 0;}
0 0
- HDU 1896 Stones
- HDU 1896 Stones
- hdu 1896 Stones
- HDU 1896 Stones
- HDU 1896 Stones
- hdu 1896 Stones
- hdu 1896 stones 队列
- hdu 1896 stones
- HDU 1896 Stones
- HDU-1896-Stones
- HDU 1896 Stones (Priority_queue)
- HDU 1896 Stones
- HDU 1896 Stones
- hdu 1896 Stones
- HDU 1896 Stones
- hdu 1896 Stones
- HDU-1896-Stones
- HDU 1896 Stones
- [Android分享] ViewPager的setOnPageChangeListener方法详解
- hibernate 之 getCurrentSession() 详解
- 编码问题详解
- 排序算法和设计模式
- vim搜索设置高亮
- HDU 1896 Stones
- 黑马程序员————C语言指针
- 如何在CentOS 6上通过YUM安装Nginx和PHP-FPM
- 从标准输入读取几行输入,每行输入都要打印到标准输出上,前面加上行号。
- kettle介绍
- poj 1821 dp+单调队列
- Linux shell 脚本中的归档指令
- 《Getting Started with WebRTC》第二章 WebRTC技术介绍
- Arrays.asList使用