結果

問題 No.198 キャンディー・ボックス2
ユーザー eri
提出日時 2015-07-25 03:34:15
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 360 bytes
コンパイル時間 620 ms
コンパイル使用メモリ 65,208 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-16 04:35:10
合計ジャッジ時間 1,482 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int b, n; cin >> b >> n;
	vector<int> c(n);
	int sum = b;
	for (int i = 0; i < n; i++){
		cin >> c[i];
		sum += c[i];
	}
	sort(c.begin(), c.end());
	int t = min(sum / n, c[n / 2]);
	int ans = 0;
	for (int ci : c){ ans += abs(ci - t); }
	cout << ans << endl;
	return 0;
}
0