Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text;
- namespace fundamental14
- {
- class MainClass
- {
- public static void Main()
- {
- double saveMoney = double.Parse(Console.ReadLine());
- List<int> drums = Console.ReadLine().
- Split().
- Select(int.Parse).
- ToList();
- List<int> powerRed = new List<int>(drums);
- string input;
- input = DrumsResult(ref saveMoney, drums, powerRed);
- Console.WriteLine(string.Join(" ", powerRed));
- Console.WriteLine("Gabsy has {0:f2}lv.", saveMoney);
- }
- private static string DrumsResult(ref double saveMoney, List<int> drums, List<int> powerRed)
- {
- string input;
- while ((input = Console.ReadLine()) != "Hit it again, Gabsy!")
- {
- int power = int.Parse(input);
- for (int i = 0; i < drums.Count; i++)
- {
- powerRed[i] -= power;
- if (powerRed[i] <= 0)
- {
- int replaseDrum = drums[i] * 3;
- if (replaseDrum >= saveMoney)
- {
- drums.RemoveAt(i);
- powerRed.RemoveAt(i);
- i--;
- }
- else
- {
- powerRed[i] = drums[i];
- saveMoney -= replaseDrum;
- }
- }
- }
- }
- return input;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement