結果
| 問題 | No.609 Noelちゃんと星々 |
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-05-06 06:37:48 |
| 言語 | C(gnu17) (gcc 15.2.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 777 bytes |
| 記録 | |
| コンパイル時間 | 395 ms |
| コンパイル使用メモリ | 37,888 KB |
| 最終ジャッジ日時 | 2026-02-22 03:18:02 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 25 |
ソースコード
// yukicoder: No.609 Noelちゃんと星々
// 2019.5.5 bal4u
#include <stdio.h>
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in() // 整数の入力(負数対応)
{
int n = 0, c = gc();
if (c == '-') { c = gc();
do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
return -n;
}
do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
return n;
}
#define ABS(x) ((x)>=0?(x):-(x))
int y[100005];
int main()
{
int i, N, t;
long long s, min;
N = in();
s = 0; for (i = 0; i < N; i++) {
y[i] = in();
s += y[i];
}
t = (int)(s / N);
min = 0; for (i = 0; i < N; i++) min += ABS(y[i]-t);
if (s % N) {
t++;
s = 0; for (i = 0; i < N; i++) s += ABS(y[i]-t);
if (s < min) min = s;
}
printf("%lld\n", min);
return 0;
}
bal4u