Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace smart_lilly
- {
- class Program
- {
- static void Main(string[] args)
- {
- var wantedHeight = int.Parse(Console.ReadLine());
- var start = wantedHeight - 30;
- var success = 0;
- var unsuccess = 0;
- var unsuccessFull = new List<int>();
- var isTrue = false;
- var curr = start;
- for (int i = 0; i < int.MaxValue; i++)
- {
- var height = int.Parse(Console.ReadLine());
- if (height>curr && height<=wantedHeight)
- {
- curr += 5;
- if (curr>wantedHeight)
- {
- success++;
- Console.WriteLine($"Tihomir succeeded, he jumped over {wantedHeight}cm after {success + unsuccess} jumps.");
- break;
- }
- else
- {
- success++;
- unsuccessFull.Clear();
- }
- }
- else if (height <= curr )
- {
- unsuccess++;
- unsuccessFull.Add(height);
- for (int j = 2; j < unsuccessFull.Count; j++)
- {
- if (unsuccessFull[j] <= curr && unsuccessFull[j - 1] <= curr && unsuccessFull[j-2] <= curr)
- {
- isTrue = true;
- }
- }
- if (isTrue)
- {
- Console.WriteLine($"Tihomir failed at {curr}cm after {success+unsuccess} jumps.");
- break;
- }
- }
- else if (height>wantedHeight)
- {
- success++;
- Console.WriteLine($"Tihomir succeeded, he jumped over {wantedHeight}cm after {success+unsuccess} jumps.");
- break;
- }
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement