|
|
вернуться в форумWA #13, what's the issue? so what is the trick with the test 13? Here is my code: public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int k = input.nextInt(); long[] arr = new long[k]; long first = 20000000000000L; int first_location = 0; long second = 2000000000000L; for (int i = 0; i < k; i++) arr[i] = input.nextInt();
for (int i = 0; i < k; i++) if (arr[i] < first) { first = arr[i]; first_location = i; } arr[first_location] = 0;
for (int i = 0; i < k; i++) if (arr[i] < second && arr[i] != 0) second = arr[i]; long answer = first + second - n; if (answer > 0) System.out.println(answer); else System.out.println(0);
} |
|
|