結果
問題 | No.609 Noelちゃんと星々 |
ユーザー |
![]() |
提出日時 | 2018-07-02 21:36:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 350 bytes |
コンパイル時間 | 591 ms |
コンパイル使用メモリ | 70,108 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-01 01:38:52 |
合計ジャッジ時間 | 3,208 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include<iostream>#include<algorithm>using namespace std;using ll = long long;int main(){ll n;cin >> n;ll a[100000];for(int i=0;i<n;i++)cin >> a[i];sort(a,a+n);ll x=a[n/2];ll y=a[(n+1)/2];ll sumx=0,sumy=0;for(int i=0;i<n;i++){sumx+=abs(a[i]-x);sumy+=abs(a[i]-y);}cout << min(sumx,sumy) << endl;}