Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Mock5_mineralWater {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int smallBottles = scanner.nextInt();
- int bigBottles = scanner.nextInt();
- int truckCapacity = scanner.nextInt();
- while (bigBottles > 0 && truckCapacity >= 0) {
- if (truckCapacity < 5) {
- break;
- }
- bigBottles--;
- truckCapacity -= 5;
- }
- int difference = truckCapacity - smallBottles;
- if (difference > 0) {
- System.out.println("-1");
- } else if (difference == 0) {
- System.out.println(smallBottles);
- } else {
- System.out.println(truckCapacity);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement