結果

問題 No.198 キャンディー・ボックス2
ユーザー zaichu
提出日時 2016-02-06 00:50:26
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 294 bytes
コンパイル時間 1,354 ms
コンパイル使用メモリ 162,924 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-16 09:46:47
合計ジャッジ時間 2,312 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
	long long b,n;
	cin >> b >> n;
	vector<long long> c(n);
	for(auto &a:c) cin >> a,b += a;
	sort(c.begin(),c.end());
	long long ans = 0;
	for(int i = 0; i < n; i++) ans += abs(c[i] - min(b/n,c[n/2]));
	cout << ans << endl;
	return 0;
}
0