結果

問題 No.198 キャンディー・ボックス2
ユーザー kuuso1kuuso1
提出日時 2015-04-29 00:45:07
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,273 bytes
コンパイル時間 4,353 ms
コンパイル使用メモリ 105,568 KB
実行使用メモリ 25,568 KB
最終ジャッジ日時 2023-09-19 03:00:12
合計ジャッジ時間 6,731 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
21,428 KB
testcase_01 AC 61 ms
23,556 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 61 ms
23,468 KB
testcase_10 AC 61 ms
21,404 KB
testcase_11 AC 61 ms
21,524 KB
testcase_12 AC 60 ms
21,572 KB
testcase_13 WA -
testcase_14 AC 61 ms
23,596 KB
testcase_15 AC 61 ms
21,564 KB
testcase_16 AC 61 ms
23,636 KB
testcase_17 AC 62 ms
23,568 KB
testcase_18 AC 61 ms
23,524 KB
testcase_19 AC 62 ms
21,588 KB
testcase_20 AC 60 ms
21,440 KB
testcase_21 AC 61 ms
21,480 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 60 ms
21,560 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long trgt=0;
		long tot=A.Sum();
		long apnd=tot%N;
		trgt=(tot-apnd)/N;
		if(N-tot%N <tot%N && (N-tot%N)<=B){
			apnd=N-tot%N;
			trgt++;
		}
		
		long[] T=new long[N];
		for(int i=0;i<N;i++){
			T[i]=(i<tot%N)?(tot/N+1):tot/N;
		}
		
		Array.Sort(A,(x,y)=>-x.CompareTo(y));
		long sum=apnd;
		for(int i=0;i<N;i++)sum+=Math.Abs(A[i]-T[i]);
		
		Console.WriteLine(sum);
	}
	int N,B;
	long[] A;
	public Sol(){
		B=ri();
		N=ri();
		A=new long[N];
		for(int i=0;i<N;i++)A[i]=rl();
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
0