Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
37621 | 林芳菲 | 【J】T1 | C++ | 通过 | 100 | 56 MS | 1036 KB | 768 | 2025-04-23 20:52:35 |
#include <cstdio> #include <iostream> #include <algorithm> using namespace std; int n, a[200010], b[200010]; int main() { // freopen("bamboo.in", "r", stdin); // freopen("bamboo.out", "w", stdout); cin >> n; int ans = 0; for (int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; if (b[i] < a[i] - b[i]) b[i] = a[i] - b[i]; ans = max(ans, a[i]); } int mx_p = 0, mxx_p = 0; for (int i = 1; i <= n; i++) if (b[i] > b[mx_p]) mx_p = i; for (int i = 1; i <= n; i++) if (b[i] > b[mxx_p]) if (i != mx_p) mxx_p = i; cout << max(ans, b[mx_p] + b[mxx_p]) << endl; fclose(stdin); fclose(stdout); return 0; }