結果
| 問題 |
No.198 キャンディー・ボックス2
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2015-04-29 00:35:01 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,146 bytes |
| コンパイル時間 | 967 ms |
| コンパイル使用メモリ | 107,520 KB |
| 実行使用メモリ | 18,688 KB |
| 最終ジャッジ日時 | 2024-07-05 05:26:02 |
| 合計ジャッジ時間 | 2,811 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 5 WA * 21 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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 sum=apnd;
for(int i=0;i<N;i++)sum+=Math.Abs(A[i]-trgt);
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));}
}
kuuso1