Guest User

Untitled

a guest
Jan 24th, 2017
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. namespace Problem01Prospect_In_Hospitality
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. class Prospect_In_Hospitality
  10. {
  11. static void Main()
  12. {
  13. string[] driveName = Console.ReadLine()
  14. .Split(new char[] { ' ' }
  15. , StringSplitOptions.RemoveEmptyEntries);
  16. if (driveName.Length == 0)
  17. {
  18. return;
  19. }
  20.  
  21. double[] zone = Console.ReadLine()
  22. .Split(new char[] { ' ' }
  23. , StringSplitOptions.RemoveEmptyEntries)
  24. .Select(double.Parse).ToArray();
  25. long[] checkpoint = Console.ReadLine()
  26. .Split(new char[] { ' ' }
  27. , StringSplitOptions.RemoveEmptyEntries)
  28. .Select(long.Parse).ToArray();
  29.  
  30. int countName = 0;
  31. long count = 0;
  32. long count1 = 0;
  33.  
  34. double sum = 0;
  35. long index = 0;
  36. double letters = 0;
  37.  
  38. for (int i = 0; i < driveName[countName].Length; i++)
  39. {
  40. count = 0;
  41. count1 = 0;
  42. sum = 0;
  43.  
  44. char temporarityLetter = driveName[countName][0];
  45.  
  46. //if (temporarityLetter >= 'a' && temporarityLetter <= 'z')
  47. //{
  48. letters = driveName[countName][0] - 32;
  49. //}
  50. //else
  51. //{
  52. letters = driveName[countName][0];
  53. //}
  54.  
  55.  
  56.  
  57. for (int z = 0; z < zone.Length; z++)
  58. {
  59. bool b1 = checkpoint.Any(x => x == z);
  60. if (b1 == false)
  61. {
  62. if (count >= 1)
  63. {
  64. sum -= zone[z];
  65. count1++;
  66. }
  67. else
  68. {
  69. sum = letters - zone[z];
  70. count1++;
  71. if (sum < 0)
  72. {
  73. index = z;
  74. break;
  75. }
  76. }
  77. }
  78. else
  79. {
  80. if (count1 >= 1)
  81. {
  82. sum += zone[z];
  83. count++;
  84. }
  85. else
  86. {
  87. sum = letters + zone[z];
  88. count++;
  89. }
  90. }
  91. index = z;
  92. if (sum < 0)
  93. {
  94. break;
  95. }
  96. }
  97. if (sum >= 0)
  98. {
  99. Console.WriteLine("{0} - fuel left {1:f2}", driveName[i], sum);
  100. }
  101. if (sum <= 0)
  102. {
  103. Console.WriteLine($"{driveName[i]} - reached {index}");
  104. }
  105.  
  106. countName++;
  107. if (countName >= driveName.Length)
  108. {
  109. return;
  110. }
  111. }
  112. }
  113. }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment