Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int quantity = Integer.parseInt(scanner.nextLine()),
- sugar, flour, maxSugar = 0, maxFlour = 0;
- double totalSugar = 0, totalFlour = 0;
- for (int i = 0; i < quantity; i++) {
- sugar = Integer.parseInt(scanner.nextLine());
- flour = Integer.parseInt(scanner.nextLine());
- if (maxSugar < sugar) {
- maxSugar = sugar;
- }
- if (maxFlour < flour) {
- maxFlour = flour;
- }
- totalSugar += sugar;
- totalFlour += flour;
- }
- System.out.println("Sugar: " + (int) Math.ceil(totalSugar / 950) + "\nFlour: " + (int) Math.ceil(totalFlour / 750)
- + "\nMax used flour is " + maxFlour + " grams, max used sugar is " + maxSugar + " grams.\n"
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement