Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. package pb1;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class ControlNumber2 {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int N = Integer.parseInt(scanner.nextLine());
  10. int M = Integer.parseInt(scanner.nextLine());
  11. int controlNumber = Integer.parseInt(scanner.nextLine());
  12. int sum = 0;
  13. int moves = 0;
  14.  
  15. for (int i = 1; i <= N ; i++) {
  16. int firstNum = Integer.parseInt(scanner.nextLine());
  17. sum = sum + firstNum * 2;
  18. for (int j = M; j >= 1 ; j--) {
  19. int secondNum = Integer.parseInt(scanner.nextLine());
  20. sum = sum + secondNum * 3;
  21. }
  22. moves++;
  23. if (sum >= controlNumber) {
  24. System.out.printf("%d moves", moves);
  25. System.out.println();
  26. System.out.printf("Score: %d >= %d", sum , controlNumber);
  27. return;
  28. }
  29. else if (sum < controlNumber) {
  30. System.out.printf("%d moves", moves);
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement