Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
37620 林芳菲 【J】T1 C++ 运行出错 0 1 MS 260 KB 762 2025-04-23 20:52:22

Tests(0/10):


#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; }


测评信息: