結果
問題 |
No.972 選び方のスコア
|
ユーザー |
👑 |
提出日時 | 2020-01-17 21:50:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 440 bytes |
コンパイル時間 | 1,135 ms |
コンパイル使用メモリ | 74,068 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 19:33:17 |
合計ジャッジ時間 | 4,189 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 24 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int n;cin>>n; if(n < 3){ cout << 0 << endl; return 0; } vector<int> a(n); for(int i = 0; n > i; i++){ cin>>a[i]; } int ans = 0; sort(a.begin(),a.end()); int nw = a[0]; int ce = a[0]; for(int i = 1; i < n-i; i++){ nw += a[i]+a[n-i]; ce = a[i]; ans = max(ans,nw-(i*2+1)*ce); } cout << ans << endl; }