結果
問題 | No.609 Noelちゃんと星々 |
ユーザー |
|
提出日時 | 2017-12-22 15:33:15 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 435 bytes |
コンパイル時間 | 583 ms |
コンパイル使用メモリ | 64,516 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-17 23:10:48 |
合計ジャッジ時間 | 2,489 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>using namespace std;typedef long long LL;int main(int argc, char* argv[]){int N;cin>>N;vector<LL> A(N,0);LL x;int i;for (i=0;i<N;i++){cin>>x;A[i]=x;}sort(A.begin(),A.end());LL P;if (N%2==1){P=A[N/2];}else{P=(A[N/2-1]+A[N/2])/2;}LL aw=0;for (i=0;i<N;i++){x=A[i]-P;if (x<0){x=-x;}aw+=x;}cout<<aw<<endl;return 0;}