Advertisement
Guest User

Untitled

a guest
Oct 14th, 2022
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MineralWater2 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int small = Integer.parseInt(scanner.nextLine());
  7. int big = Integer.parseInt(scanner.nextLine());
  8. int capacity = Integer.parseInt(scanner.nextLine());
  9.  
  10.  
  11. int loadedBig = capacity/5;
  12.  
  13. if(loadedBig>big){
  14. loadedBig=big;
  15. }
  16.  
  17.  
  18. int neededSmall = capacity-5*loadedBig;
  19.  
  20. if(neededSmall > small){
  21. System.out.println("-1");
  22. }else{
  23. System.out.println(neededSmall);
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement