杭电1896 queue 优先队列
来源:互联网 发布:同花顺mac版功能全吗 编辑:程序博客网 时间:2024/05/22 16:38
Because of the wrong status of the bicycle, Sempr begin to walk east to west every morning and walk back every evening. Walking may cause a little tired, so Sempr always play some games this time.
There are many stones on the road, when he meet a stone, he will throw it ahead as far as possible if it is the odd stone he meet, or leave it where it was if it is the even stone. Now give you some informations about the stones on the road, you are to tell me the distance from the start point to the farthest stone after Sempr walk by. Please pay attention that if two or more stones stay at the same position, you will meet the larger one(the one with the smallest Di, as described in the Input) first.
Input
In the first line, there is an Integer T(1<=T<=10), which means the test cases in the input file. Then followed by T test cases. For each test case, I will give you an Integer N(0
#include<iostream>#include<algorithm>#include<queue>using namespace std;struct node{ friend bool operator<(node a1,node a2)//优先队列 判断 { if(a1.a==a2.a) //如果石头的位置一样 这扔的远的排在队列前面 return a1.b>a2.b; return a1.a>a2.a; } int a,b;}as;int main(){ int i,j,k,l; cin>>l; while(l--) { cin>>k; priority_queue<node>a; for(i=0;i<k;i++) { cin>>as.a>>as.b; a.push(as);//入队 } int n=1,sum=0; while(!a.empty())//如果队列为空 结束 { as=a.top(); a.pop(); if(n%2!=0)//如果 步数为偶数 进行 丢石子 { as.a+=as.b;//石子被丢到的位置 sum=as.a; a.push(as);//入队 } n++; } cout<<sum<<endl; } return 0;}
- 杭电1896 queue 优先队列
- hdu 杭电1509 Windows Message Queue【优先队列】
- Windows Message Queue(杭电oj1509)(优先队列)
- 【杭电oj】1509 - Windows Message Queue(优先队列)
- 【杭电-oj】-1509-Windows Message Queue(优先队列)
- 【杭电OJ】1509--Windows Message Queue(优先队列)
- hdu 杭电1896 Stones【优先队列】
- 杭电1896 Stones(优先队列)
- 杭电-1896 Stones(优先队列)
- 杭电1434 优先队列
- priority queue 优先队列
- priority queue 优先队列
- 优先队列priority queue
- 基础queue优先队列
- 【杭电oj】1896 - Stones(优先队列)
- 杭电 2822 优先队列+光搜
- C++ Priority Queue(优先队列)
- STL-优先队列(priority queue)
- PHP递归实现无限分类数组处理
- Java中Volatile关键字详解
- elasticsearch源码分析之Transport(五)
- AsyncTask异步任务请求的流程
- Java NIO系列教程(九) ServerSocketChannel
- 杭电1896 queue 优先队列
- Linux学习笔记12
- Hibernate与 MyBatis的比较
- Java 替换文件夹下所有文件中指定的内容
- python学习第一课 requests
- 图片的处理(缩放、 平移、镜面、倒影、模糊、颜色)
- app
- 集群作业提交
- mysql 乱码解决 数据库