Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
222891 | 232214陈皓轩 | *小美的加法 | C++ | 解答错误 | 40 | 44 MS | 3396 KB | 637 | 2023-12-17 13:55:16 |
#include <iostream> #include <algorithm> #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]; } sort(a + 1,a + n + 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]); } cout << ans; }