Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PowerPlants
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] plantsLife = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- int currentDay = 0;
- int seasonDays = plantsLife.Length;
- while (ArrayPlantsLife(plantsLife))
- {
- for (int cnt = 0; cnt < plantsLife.Length; cnt++)
- {
- if (plantsLife[cnt] == 0)
- {
- continue;
- }
- if ((currentDay % seasonDays) != cnt)
- {
- plantsLife[cnt]--;
- }
- }
- currentDay++;
- if (currentDay % seasonDays == 0)
- {
- for (int k = 0; k < plantsLife.Length; k++)
- {
- if (plantsLife[k] != 0)
- {
- plantsLife[k]++;
- }
- }
- }
- }
- int seasons = (currentDay -1) / seasonDays;
- string FU = String.Empty;
- if (seasons == 1)
- {
- FU = "season";
- }
- else
- {
- FU = "seasons";
- }
- Console.WriteLine($"survived {currentDay} days ({seasons} {FU})");
- }
- static bool ArrayPlantsLife(int[] plantsLife)
- {
- for (int cnt = 0; cnt < plantsLife.Length; cnt++)
- {
- if (plantsLife[cnt] > 0)
- {
- return true;
- }
- }
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement