結果

問題 No.972 選び方のスコア
ユーザー pekempeypekempey
提出日時 2020-01-17 21:41:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 683 bytes
コンパイル時間 1,606 ms
コンパイル使用メモリ 169,640 KB
実行使用メモリ 6,444 KB
最終ジャッジ日時 2023-09-08 02:04:32
合計ジャッジ時間 5,657 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
6,200 KB
testcase_01 AC 95 ms
6,240 KB
testcase_02 AC 90 ms
5,976 KB
testcase_03 AC 44 ms
4,496 KB
testcase_04 AC 86 ms
6,156 KB
testcase_05 AC 87 ms
6,236 KB
testcase_06 AC 88 ms
6,160 KB
testcase_07 AC 71 ms
5,368 KB
testcase_08 AC 77 ms
6,288 KB
testcase_09 AC 74 ms
5,872 KB
testcase_10 AC 77 ms
6,388 KB
testcase_11 AC 82 ms
6,260 KB
testcase_12 AC 83 ms
6,156 KB
testcase_13 AC 83 ms
6,172 KB
testcase_14 AC 83 ms
6,196 KB
testcase_15 AC 83 ms
6,160 KB
testcase_16 AC 85 ms
6,160 KB
testcase_17 AC 84 ms
6,424 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,384 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,384 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  int N; cin >> N;
  vector<ll> A(N); rep(i, N) cin >> A[i];
  sort(range(A));
  vector<ll> S(N + 1); rep(i, N) S[i + 1] = S[i] + A[i];
  ll ans = 0;
  rep(i, N) {
    int k = min(i, N - (i + 1));
    ans = max(ans, (S[N] - S[N - k]) + (S[i] - S[i - k]) + A[i] - A[i] * (2*k+1));
  }
  rep(i, N-1) {
    int k = min(i, N - (i + 2));
    ans = max(ans, (S[N] - S[N - k]) + (S[i] - S[i - k]) + A[i] + A[i + 1] - (A[i] + A[i+1])*(k+1));
  }
  cout << ans << endl;
}
0