Advertisement
YavorGrancharov

Rainer

Jan 2nd, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace Rainer
  5. {
  6.     class MainClass
  7.     {
  8.         public static void Main(string[] args)
  9.         {
  10.             int[] inputSequence = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  11.  
  12.             int[] initialRaindropState = inputSequence.Take(inputSequence.Length - 1).ToArray();
  13.  
  14.             int[] currentRaindropState = initialRaindropState.ToArray();
  15.  
  16.             int currentIndex = inputSequence.Last();
  17.  
  18.             bool isWet = false;
  19.  
  20.             int steps = 0;
  21.             while (!isWet)
  22.             {
  23.                 for (int i = 0; i < currentRaindropState.Length; i++)
  24.                 {
  25.                     currentRaindropState[i]--;
  26.                 }
  27.  
  28.                 for (int i = 0; i < currentRaindropState.Length; i++)
  29.                 {
  30.                     if (currentRaindropState[i] == 0 && currentIndex == i)
  31.                     {
  32.                         isWet = true;
  33.                         break;
  34.                     }
  35.                 }
  36.  
  37.                 if (isWet)
  38.                 {
  39.                     break;
  40.                 }
  41.  
  42.                 for (int i = 0; i < currentRaindropState.Length; i++)
  43.                 {
  44.                     if (currentRaindropState[i] == 0)
  45.                     {
  46.                         currentRaindropState[i] = initialRaindropState[i];
  47.                     }
  48.                 }
  49.                 currentIndex = int.Parse(Console.ReadLine());
  50.                 steps++;
  51.             }
  52.             Console.WriteLine(string.Join(" ", currentRaindropState));
  53.             Console.WriteLine(steps);
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement