Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
314164 太高24董烨霖 *小美的加法 C++ 通过 100 44 MS 3396 KB 644 2024-12-12 17:05:20

Tests(10/10):


#include <iostream> #define int __int128 using namespace std; int n; int cnt[100005], a[100005]; istream& operator>>(istream& in, int &x) { long long y; in >> y; x = y; return in; } ostream& operator<<(ostream& out, int x) { string s; while (x) { s = char(x % 10 ^ 48) + s; x /= 10; } out << s; return out; } signed main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; cnt[i] = a[i] + cnt[i - 1]; } int ans(cnt[n]); for (int i = 1; i < n; i++) { ans = max(ans, cnt[n] - a[i] - a[i + 1] + a[i] * a[i + 1]); } ans = max(ans, cnt[n] - a[1] - a[n] + a[1] * a[n]); cout << ans; }


测评信息: