标签:
Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 1373 Accepted Submission(s): 858
1 #include<stdio.h> 2 #include<queue> 3 using namespace std; 4 struct Node{ 5 int position,dis; 6 friend bool operator < (Node a,Node b){ 7 if(a.position!=b.position)return a.position>b.position; 8 else return a.dis>b.dis; 9 } 10 }; 11 int main(){ 12 int T,N,k; 13 Node m; 14 scanf("%d",&T); 15 while(T--){k=0;priority_queue<Node>stone; 16 scanf("%d",&N); 17 while(N--)scanf("%d%d",&m.position,&m.dis),stone.push(m); 18 while(!stone.empty()){k++; 19 if(k&1)m=stone.top(),m.position+=m.dis,stone.push(m); 20 stone.pop(); 21 if(stone.empty())printf("%d\n",stone.top().position); 22 } 23 } 24 return 0; 25 }
标签:
原文地址:http://www.cnblogs.com/handsomecui/p/4683550.html