結果
| 問題 |
No.972 選び方のスコア
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-02 02:20:58 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 980 bytes |
| コンパイル時間 | 1,370 ms |
| コンパイル使用メモリ | 160,364 KB |
| 実行使用メモリ | 6,656 KB |
| 最終ジャッジ日時 | 2024-06-27 14:35:56 |
| 合計ジャッジ時間 | 4,996 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 7 |
ソースコード
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
/*
for(i=0; i<N; i++)
cin >> a[i];
*/
ll moP(ll x, ll n) {
ll res=1;
while(n>0) {
if(n&1) moC(res, *, x);
moC(x, *, x);
n>>=1;
}
return res;
}
int main(void) {
ll i, j, k;
ll N;
cin >> N;
ll a[MAX*2];
ll s[MAX*2]={};
for(i=1; i<=N; i++) cin >> a[i];
sort(a+1, a+N+1);
for(i=1; i<=N; i++) s[i]=s[i-1]+a[i];
ll ans=0;
for(ll m=1; m<=N/2; m++) {
ll t=(s[N]-s[N-(m-1)])+s[m-1]-a[m]*(m-1)*2;
chmax(ans, t);
}
for(ll m=1; m<=N/2; m++) {
ll t=(s[N]-s[N-(m-1)])+s[m-1]-(a[m]+a[m+1])*(m-1);
chmax(ans, t);
}
pt(ans);
}