Run ID Author Problem Lang Verdict Score Time Memory Code Length Submit Time
222900 232214陈皓轩 *小美的加法 C++ Accepted 100 28 MS 3396 KB 644 2023-12-17 14:02:27

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


Judgement Protocol: