提交时间:2023-08-09 14:29:55

运行 ID: 81512

#include<bits/stdc++.h> using namespace std; int n; int a[100010]; int b[100010]; int ans; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; } sort(a + 1, a + 1 + n); sort(b + 1, b + 1 + n); for (int i = n; i >= 1; i--) { ans += a[i]; } ans += b[1]; if (b[n] > ans) { ans += (b[n] - ans); } cout << ans; return 0; }