Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- int malini = int.Parse(Console.ReadLine());
- int strawberries = int.Parse(Console.ReadLine());
- int cheries = int.Parse(Console.ReadLine());
- int maxJuice = int.Parse(Console.ReadLine());
- int cherryUsed = 0;
- int strawUsed = 0;
- int raspUsed = 0;
- // rightmixture = cheries > strawberries && cheries > malini;
- double maxvolumejuice = 0;
- for (int i = 0; i <= malini; i++)
- {
- for (int j = 0; j <= strawberries; j++)
- {
- for (int k = 0; k <= cheries; k++)
- {
- double juiceCurrent = k * 15 + j * 7.5 + i * 4.5;
- if (juiceCurrent <= maxJuice)
- {
- if (juiceCurrent > maxvolumejuice)
- {
- maxvolumejuice = juiceCurrent;
- cherryUsed = k;
- strawUsed = j;
- raspUsed = i;
- }
- }
- }
- }
- }
- Console.WriteLine($"{raspUsed} Raspberries, {strawUsed} Strawberries, {cherryUsed} Cherries. Juice: {maxvolumejuice} ml.");
- }
- }
Add Comment
Please, Sign In to add comment