提出 #945676
ソースコード 拡げる
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int K = Integer.parseInt(sc.next());
int T = Integer.parseInt(sc.next());
int[] cake = new int[T];
for(int i = 0; i < T; i++){
cake[i] = Integer.parseInt(sc.next());
}
int max = getArrayMax(cake);
int day = Math.max(0, (max - (K/2 + 1))*2 + (K+1) % 2);
System.out.println(day);
}
static int getArrayMax(int[] array){
int max = 0;
for(int i = 0; i < array.length; i++){
max = Math.max(max, array[i]);
}
return max;
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | B - K個のケーキ |
| ユーザ | |
| 言語 | Java8 (OpenJDK 1.8.0) |
| 得点 | 200 |
| コード長 | 622 Byte |
| 結果 | AC |
| 実行時間 | 149 ms |
| メモリ | 9680 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 200 / 200 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 0_000.txt, 0_001.txt, 0_002.txt |
| All | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 0_000.txt | AC | 129 ms | 9552 KiB |
| 0_001.txt | AC | 130 ms | 9676 KiB |
| 0_002.txt | AC | 130 ms | 9552 KiB |
| 1_003.txt | AC | 149 ms | 9552 KiB |
| 1_004.txt | AC | 134 ms | 9552 KiB |
| 1_005.txt | AC | 133 ms | 9552 KiB |
| 1_006.txt | AC | 146 ms | 9680 KiB |
| 1_007.txt | AC | 146 ms | 9556 KiB |
| 1_008.txt | AC | 132 ms | 9680 KiB |
| 1_009.txt | AC | 130 ms | 9428 KiB |