#12692: c++ AC code


bert30702 (bert30702)

學校 : 臺北市立成功高級中學
編號 : 62008
來源 : [223.197.10.194]
最後登入時間 :
2025-08-05 02:15:39

#include <bits/stdc++.h>
using namespace std;

int main(){
	int n; 
	while(cin >> n){
		priority_queue<pair<int, int> > pq;
		while(n--){
			int s, d; cin >> s >> d;
			pq.push({d, s});
		}
		int maxx = 0;
		for(int now = 0; pq.size(); pq.pop()){
			now += pq.top().second;
			maxx = max(maxx, pq.top().first + now);
		}
		cout << maxx << endl;
	}
}