Advertisement
Guest User

Untitled

a guest
Aug 14th, 2023
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace smart_lilly
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11.  
  12. var wantedHeight = int.Parse(Console.ReadLine());
  13. var start = wantedHeight - 30;
  14. var success = 0;
  15. var unsuccess = 0;
  16. var unsuccessFull = new List<int>();
  17. var isTrue = false;
  18. var curr = start;
  19. for (int i = 0; i < int.MaxValue; i++)
  20. {
  21. var height = int.Parse(Console.ReadLine());
  22. if (height>curr && height<=wantedHeight)
  23. {
  24. curr += 5;
  25. if (curr>wantedHeight)
  26. {
  27. success++;
  28. Console.WriteLine($"Tihomir succeeded, he jumped over {wantedHeight}cm after {success + unsuccess} jumps.");
  29. break;
  30.  
  31. }
  32. else
  33. {
  34. success++;
  35. unsuccessFull.Clear();
  36. }
  37.  
  38. }
  39. else if (height <= curr )
  40. {
  41. unsuccess++;
  42. unsuccessFull.Add(height);
  43. for (int j = 2; j < unsuccessFull.Count; j++)
  44. {
  45. if (unsuccessFull[j] <= curr && unsuccessFull[j - 1] <= curr && unsuccessFull[j-2] <= curr)
  46. {
  47. isTrue = true;
  48. }
  49. }
  50.  
  51. if (isTrue)
  52. {
  53. Console.WriteLine($"Tihomir failed at {curr}cm after {success+unsuccess} jumps.");
  54. break;
  55. }
  56. }
  57. else if (height>wantedHeight)
  58. {
  59. success++;
  60. Console.WriteLine($"Tihomir succeeded, he jumped over {wantedHeight}cm after {success+unsuccess} jumps.");
  61. break;
  62. }
  63. }
  64. Console.ReadKey();
  65.  
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement