結果
問題 |
No.972 選び方のスコア
|
ユーザー |
|
提出日時 | 2020-01-17 23:00:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 334 bytes |
コンパイル時間 | 634 ms |
コンパイル使用メモリ | 70,200 KB |
実行使用メモリ | 7,244 KB |
最終ジャッジ日時 | 2024-06-25 23:44:21 |
合計ジャッジ時間 | 4,068 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 7 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 7 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> using namespace std; int N; long A[2<<17]; long S[2<<17]; main() { cin>>N; for(int i=0;i<N;i++)cin>>A[i]; sort(A,A+N); for(int i=0;i<N;i++)S[i+1]=S[i]+A[i]; long ans=0; for(int i=1;i<N-1;i++) { long L=min(i,N-1-i); ans=max(ans,S[N]-S[N-L]+S[i]-S[i-L]-2*L*A[i]); } cout<<ans<<endl; }