結果
問題 |
No.609 Noelちゃんと星々
|
ユーザー |
![]() |
提出日時 | 2019-03-19 01:16:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 600 bytes |
コンパイル時間 | 584 ms |
コンパイル使用メモリ | 65,780 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-07-19 19:26:41 |
合計ジャッジ時間 | 5,378 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 6 TLE * 1 -- * 18 |
ソースコード
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <math.h> using ll = long long; using namespace std; const int MOD = 1e9+7; int main() { int N; ll ave = 0, ans = (1LL << 62); cin >> N; vector<ll> Y(N); for(int i = 0; i < N; i++) { cin >> Y[i]; ave += Y[i]; } ave /= N; ll sum; do { sum = 0; for(int i = 0; i < N; i++) { sum += abs(Y[i] - ave); } ans = min(ans, sum); ave++; } while (sum == ans); cout << ans << endl; return 0; }