扔石头的问题Stone

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. 


InputIn 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


OutputJust output one line for one test case, as described in the Description. 

Sample Input
2
2
1 5
2 4
2
1 5
6 6

就是扔石头的问题,因为涉及到优先级,所以用到一个operator函数

题目大意就是:一个人扔石头,碰到奇数个石头就扔,仍di远,偶数不处理,如果两个石头在同一个位置,仍小的。

#include
#include
using namespace std;
struct stone
{
	int  pi,di;
}t;
bool operator<(stone a,stone b)
{
	if(a.pi==b.pi) 
	return a.di>b.di;
	return a.pi>b.pi;
}
int main()
{
    int n,i;
    scanf("%d",&n);
    priority_queueq;    
    while(n--)
    {
    	int m;
    	scanf("%d",&m);
    	for(i=0;i



你可能感兴趣的:(acm)