原题链接
solution:简单的优先队列模拟
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t, n, res;
cin >> t;
while (t--)
{
cin >> n;
priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int>> > q;
for (int i = 0; i < n; ++i)
{
int a, b;
cin >> a >> b;
q.push(make_pair(a, b));
}
while (!q.empty()){
q.push(make_pair(q.top().first + q.top().second, q.top().second));
q.pop();
res = q.top().first;
q.pop();
}
cout << res << endl;
}
return 0;
}