結果
問題 | No.198 キャンディー・ボックス2 |
ユーザー |
|
提出日時 | 2019-08-08 23:03:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 332 bytes |
コンパイル時間 | 2,121 ms |
コンパイル使用メモリ | 196,360 KB |
最終ジャッジ日時 | 2025-01-07 11:02:25 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 WA * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll b, n; cin>>b>>n; ll a[n]; for (int i=0;i<n;i++) { cin>>a[i]; b+=a[i]; } sort(a,a+n); int c=min(b/n,a[n/2]); int ans=0; for (int i=0;i<n;i++) ans+=abs(a[i]-c); cout<<ans<<endl; return 0; }