結果
問題 |
No.972 選び方のスコア
|
ユーザー |
|
提出日時 | 2020-01-17 22:16:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 643 bytes |
コンパイル時間 | 1,693 ms |
コンパイル使用メモリ | 169,144 KB |
実行使用メモリ | 6,784 KB |
最終ジャッジ日時 | 2024-06-25 20:58:25 |
合計ジャッジ時間 | 5,220 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 7 |
ソースコード
#include "bits/stdc++.h" using namespace std; typedef long long ll; const int INF = (1<<30); const ll INFLL = (1ll<<60); const ll MOD = (ll)(1e9+7); #define l_ength size void mul_mod(ll& a, ll b){ a *= b; a %= MOD; } void add_mod(ll& a, ll b){ a = (a<MOD)?a:(a-MOD); b = (b<MOD)?b:(b-MOD); a += b; a = (a<MOD)?a:(a-MOD); } ll s[225816],a[225816]; int main(void){ int n,i; ll tmp,ans=0ll; cin >> n; for(i=0; i<n; ++i){ cin >> a[i]; } sort(a,a+n); for(i=0; i<n; ++i){ s[i+1] = s[i]+a[i]; } for(i=(n-1)/2; i>0; --i){ tmp = s[i]+s[n]-s[n-i]; tmp -= a[i]*i*2; ans = max(ans,tmp); } cout << ans << endl; return 0; }