标签:
2 2 1 5 2 4 2 1 5 6 6
11 12
#include <iostream> #include<queue> #include<cstring> #include<cstdio> using namespace std; int i,t,n,k; struct node { int p,d; }; struct cmp { bool operator()(node a,node b) { if (a.p==b.p) return a.d>b.d; else return a.p>b.p; } }; int main() { scanf("%d",&t); for(;t>0;t--) { priority_queue<node,vector<node>,cmp> s; scanf("%d",&n); node w; for(i=1;i<=n;i++) { scanf("%d%d",&w.p,&w.d); s.push(w); } k=0; while(!s.empty()) { w=s.top(); s.pop(); k++; if (k%2!=0) { w.p+=w.d; s.push(w); } } printf("%d\n",w.p); } return 0; }
标签:
原文地址:http://www.cnblogs.com/stepping/p/5669066.html