結果

問題 No.198 キャンディー・ボックス2
ユーザー kapo
提出日時 2016-05-24 11:45:33
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 357 bytes
コンパイル時間 449 ms
コンパイル使用メモリ 58,860 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-07 03:47:41
合計ジャッジ時間 1,399 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 6 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>

#define rep(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;

int main(void)
{
	int b, n, t;
	cin >> b >> n;

	int *c = new int[n];
	int sum = 0, avg;
	rep(i,0,n) {
		cin >> c[i];
		sum += c[i];
	}
	avg = sum / n;

	int res = 0;
	rep(i,0,n) if(c[i] != avg) res += abs(c[i]-avg);

	cout << res << endl;

	return 0;
}
0