optybg

Untitled

Feb 18th, 2017
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace PowerPlants_6
  5. {
  6.     public class PowerPlants_6
  7.     {
  8.         public static void Main(string[] args)
  9.         {
  10.             var powerLevel = Console.ReadLine()
  11.                 .Split(' ')
  12.                 .Select(int.Parse)
  13.                 .ToArray();
  14.  
  15.             var daysInSeason = powerLevel.Length;
  16.             var daysAlive = 0;
  17.  
  18.            
  19.            
  20.             for (int i = 0; i < daysInSeason-1; i++)
  21.             {
  22.                 for (int p = 0; p < powerLevel.Length; p++)
  23.                 {
  24.                     if (i!=p && powerLevel[p]!=0)
  25.                     {
  26.                         powerLevel[p] = powerLevel[p] - 1;
  27.                     }
  28.                 }
  29.                 daysAlive++;
  30.             }
  31.             Console.WriteLine(daysAlive);
  32.  
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment