結果
| 問題 |
No.198 キャンディー・ボックス2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-03 15:15:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 449 bytes |
| コンパイル時間 | 625 ms |
| コンパイル使用メモリ | 69,176 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-30 09:22:13 |
| 合計ジャッジ時間 | 1,767 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 WA * 8 |
ソースコード
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int b, n;
cin >> b >> n;
int A[n];
for(int i = 0; i < n; i++) cin >> A[i];
sort(A, A+n);
int mid = n/2;
int ans = 0;
for(int x : A) ans += abs(x-A[mid]);
if(n%2 == 0){
mid--;
int ans2 = 0;
for(int x : A) ans2 += abs(x-A[mid]);
ans = min(ans, ans2);
}
cout << ans << endl;
return 0;
}