|
|
вернуться в форумWA#13 please help me in JAVA 1.7 import java.util.*; public class Test_1874 { public static void main(String[] args) { @SuppressWarnings("resource") Scanner s = new Scanner(System.in); int n, k, m; n = s.nextInt(); k = s.nextInt(); long[] a = new long[k]; for (int i = 0; i < k; i++) { a[i] = s.nextInt(); } for (int i = 1; i < k; i++) { if (a[i] < a[i - 1]) { m = (int) a[i]; a[i] = a[i - 1]; a[i - 1] = m; } } m = (int) (n - (n - a[0]) - (n - a[1])); if (m <= 0) { System.out.println("0"); } else { System.out.println(m); } } } |
|
|