結果
| 問題 |
No.972 選び方のスコア
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-01-17 21:46:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 531 bytes |
| コンパイル時間 | 1,769 ms |
| コンパイル使用メモリ | 171,336 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-25 19:22:35 |
| 合計ジャッジ時間 | 4,057 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 7 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<ll> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
sort(a.begin(), a.end());
ll ans = 0, sumR = 0, sumL = 0;
for (int i = 1; i < n; ++i) {
if (i * 2 + 1 > n) break;
sumR += a[n - i];
sumL += a[i - 1];
ans = max(ans, sumR + sumL - a[i] * 2 * i);
}
cout << ans << "\n";
return 0;
}