結果
問題 |
No.198 キャンディー・ボックス2
|
ユーザー |
![]() |
提出日時 | 2015-04-29 00:05:21 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 797 bytes |
コンパイル時間 | 1,989 ms |
コンパイル使用メモリ | 75,244 KB |
実行使用メモリ | 54,336 KB |
最終ジャッジ日時 | 2024-07-05 05:19:36 |
合計ジャッジ時間 | 6,843 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 10 WA * 16 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner koko = new Scanner(System.in); long b = koko.nextLong(); int n = koko.nextInt(); long[] c = new long[n]; long total=0; for(int i=0; i<n; i++){ c[i]=koko.nextInt(); total = total+c[i]; } total = total + b; long ave = Math.round(total/n); long move = 0; if(ave*n<=total+b){ for(int i=0; i<n; i++){ move = move + Math.abs(c[i]-ave); } System.out.println(move); }else{ for(int i=0; i<n; i++){ move = move + Math.abs(c[i]-ave+1); } System.out.println(move); } } }