結果

問題 No.972 選び方のスコア
ユーザー utouto97utouto97
提出日時 2020-01-18 13:51:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 660 bytes
コンパイル時間 2,632 ms
コンパイル使用メモリ 149,028 KB
実行使用メモリ 4,760 KB
最終ジャッジ日時 2023-09-09 21:26:14
合計ジャッジ時間 5,399 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
4,688 KB
testcase_01 AC 92 ms
4,624 KB
testcase_02 AC 87 ms
4,588 KB
testcase_03 AC 42 ms
4,376 KB
testcase_04 AC 83 ms
4,684 KB
testcase_05 AC 83 ms
4,752 KB
testcase_06 AC 84 ms
4,748 KB
testcase_07 AC 68 ms
4,376 KB
testcase_08 AC 75 ms
4,760 KB
testcase_09 AC 72 ms
4,576 KB
testcase_10 AC 74 ms
4,580 KB
testcase_11 AC 78 ms
4,756 KB
testcase_12 AC 79 ms
4,680 KB
testcase_13 AC 80 ms
4,636 KB
testcase_14 AC 79 ms
4,636 KB
testcase_15 AC 79 ms
4,632 KB
testcase_16 AC 80 ms
4,756 KB
testcase_17 AC 81 ms
4,632 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 1 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
 */

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;


signed main() {
  int n;
  cin >> n;

  vi a(n);
  rep(i, 0, n) cin >> a[i];

  sort(all(a));
  int ans = 0, sum = 0;
  rep(i, 0, n/2){
    sum += a[i] + a[n-1-i];
    chmax(ans, sum-2*(i+1)*a[i+1]);
  }

  cout << ans << endl;

  return 0;
}

0