Submission #1675494


Source Code Expand

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int t = sc.nextInt();
		int[] a = new int[t];
		for(int i = 0 ; i < t ; i++) a[i] = sc.nextInt();
		Arrays.sort(a);
		int min = a[t - 1];
		System.out.println(Math.max(min - 1 - (k - min), 0));
	}
}

Submission Info

Submission Time
Task B - K Cakes
User kouta1612
Language Java8 (OpenJDK 1.8.0)
Score 200
Code Size 391 Byte
Status AC
Exec Time 107 ms
Memory 23764 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 10
Set Name Test Cases
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
Case Name Status Exec Time Memory
0_000.txt AC 101 ms 21204 KB
0_001.txt AC 104 ms 21844 KB
0_002.txt AC 101 ms 19924 KB
1_003.txt AC 107 ms 21844 KB
1_004.txt AC 101 ms 23764 KB
1_005.txt AC 102 ms 19796 KB
1_006.txt AC 107 ms 19668 KB
1_007.txt AC 107 ms 20684 KB
1_008.txt AC 102 ms 21204 KB
1_009.txt AC 102 ms 22996 KB