标签:
1 #include<cstdio> 2 #include<queue> 3 using namespace std; 4 5 struct stone 6 { 7 int pos; 8 int disc; 9 bool operator < (const stone &temp)const 10 { 11 if(pos==temp.pos) 12 return disc>temp.disc; 13 return pos>temp.pos; 14 } 15 }; 16 17 int main() 18 { 19 int n,t; 20 scanf("%d",&t); 21 while(t--) 22 { 23 priority_queue<stone>q; 24 scanf("%d",&n); 25 bool flag=true; 26 while(n--) 27 { 28 stone node; 29 int temp1,temp2; 30 scanf("%d%d",&temp1,&temp2); 31 node.pos=temp1; 32 node.disc=temp2; 33 q.push(node); 34 } 35 int ans; 36 while(!q.empty()) 37 { 38 stone node=q.top(); 39 q.pop(); 40 if(flag) 41 { 42 node.pos+=node.disc; 43 q.push(node); 44 } 45 ans=node.pos; 46 flag=!flag; 47 } 48 printf("%d\n",ans); 49 } 50 return 0; 51 }
标签:
原文地址:http://www.cnblogs.com/homura/p/4684096.html