Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int k = sc.nextInt();
- int n = sc.nextInt();
- int sum = 0;
- int cars = 0;
- for (int i = 0; i < n; i++) {
- cars = sc.nextInt();
- sum += cars;
- sum -= k;
- if (sum < 0) sum = 0;
- }
- System.out.println(sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment