結果
問題 | No.609 Noelちゃんと星々 |
ユーザー |
|
提出日時 | 2018-05-11 21:52:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 431 bytes |
コンパイル時間 | 723 ms |
コンパイル使用メモリ | 69,444 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-28 04:03:03 |
合計ジャッジ時間 | 2,601 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include<iostream>#include<algorithm>using namespace std;long long A[100000];int main(){int n;cin >> n;for(int i = 0; i < n; i++) cin >> A[i];sort(A, A+n);long long median = -1;if(n % 2 == 0) median = (A[n/2]+A[n/2-1])/2;else median = A[n/2];long long ans = 0;for(int i = 0; i < n; i++){ans += abs(A[i]-median);}cout << ans << endl;return 0;}