Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class MineralWater {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int small = Integer.parseInt(scanner.nextLine()); //4
- int big = Integer.parseInt(scanner.nextLine()); //0
- int capacity = Integer.parseInt(scanner.nextLine()); //11
- int result = capacity - (big * 5 + small); // 11 - (10 + 4) = -3
- if (result <= 0) {
- if( result == 0) {
- System.out.print(small); // all loaded
- } else if (capacity < (big *5) || capacity < small ){
- System.out.println(-1);
- }
- else {
- System.out.println(small + result); //small (4) + result (-3) = 1
- }
- } else {
- System.out.println(-1); // not enough bottles for the load
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement