Aliendreamer

diet juice

Feb 28th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.  
  8.         int malini = int.Parse(Console.ReadLine());
  9.         int strawberries = int.Parse(Console.ReadLine());
  10.         int cheries = int.Parse(Console.ReadLine());
  11.         int maxJuice = int.Parse(Console.ReadLine());
  12.        
  13.         int cherryUsed = 0;
  14.         int strawUsed = 0;
  15.         int raspUsed = 0;
  16.         // rightmixture = cheries > strawberries && cheries > malini;
  17.  
  18.         double maxvolumejuice = 0;
  19.  
  20.         for (int i = 0; i <= malini; i++)
  21.         {
  22.             for (int j = 0; j <= strawberries; j++)
  23.             {
  24.                 for (int k = 0; k <= cheries; k++)
  25.                 {
  26.                     double juiceCurrent = k * 15 + j * 7.5 + i * 4.5;
  27.                     if (juiceCurrent <= maxJuice)
  28.                     {
  29.                         if (juiceCurrent > maxvolumejuice)
  30.                         {
  31.                             maxvolumejuice = juiceCurrent;
  32.                             cherryUsed = k;
  33.                             strawUsed = j;
  34.                             raspUsed = i;
  35.                         }
  36.                     }
  37.                 }
  38.             }
  39.         }
  40.         Console.WriteLine($"{raspUsed} Raspberries, {strawUsed} Strawberries, {cherryUsed} Cherries. Juice: {maxvolumejuice} ml.");
  41.     }
  42. }
Add Comment
Please, Sign In to add comment