Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pb1;
- import java.util.Scanner;
- public class ControlNumber2 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int N = Integer.parseInt(scanner.nextLine());
- int M = Integer.parseInt(scanner.nextLine());
- int controlNumber = Integer.parseInt(scanner.nextLine());
- int sum = 0;
- int moves = 0;
- for (int i = 1; i <= N ; i++) {
- int firstNum = Integer.parseInt(scanner.nextLine());
- sum = sum + firstNum * 2;
- for (int j = M; j >= 1 ; j--) {
- int secondNum = Integer.parseInt(scanner.nextLine());
- sum = sum + secondNum * 3;
- }
- moves++;
- if (sum >= controlNumber) {
- System.out.printf("%d moves", moves);
- System.out.println();
- System.out.printf("Score: %d >= %d", sum , controlNumber);
- return;
- }
- else if (sum < controlNumber) {
- System.out.printf("%d moves", moves);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement