Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Problem01Prospect_In_Hospitality
- {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class Prospect_In_Hospitality
- {
- static void Main()
- {
- string[] driveName = Console.ReadLine()
- .Split(new char[] { ' ' }
- , StringSplitOptions.RemoveEmptyEntries);
- if (driveName.Length == 0)
- {
- return;
- }
- double[] zone = Console.ReadLine()
- .Split(new char[] { ' ' }
- , StringSplitOptions.RemoveEmptyEntries)
- .Select(double.Parse).ToArray();
- long[] checkpoint = Console.ReadLine()
- .Split(new char[] { ' ' }
- , StringSplitOptions.RemoveEmptyEntries)
- .Select(long.Parse).ToArray();
- int countName = 0;
- long count = 0;
- long count1 = 0;
- double sum = 0;
- long index = 0;
- double letters = 0;
- for (int i = 0; i < driveName[countName].Length; i++)
- {
- count = 0;
- count1 = 0;
- sum = 0;
- char temporarityLetter = driveName[countName][0];
- //if (temporarityLetter >= 'a' && temporarityLetter <= 'z')
- //{
- letters = driveName[countName][0] - 32;
- //}
- //else
- //{
- letters = driveName[countName][0];
- //}
- for (int z = 0; z < zone.Length; z++)
- {
- bool b1 = checkpoint.Any(x => x == z);
- if (b1 == false)
- {
- if (count >= 1)
- {
- sum -= zone[z];
- count1++;
- }
- else
- {
- sum = letters - zone[z];
- count1++;
- if (sum < 0)
- {
- index = z;
- break;
- }
- }
- }
- else
- {
- if (count1 >= 1)
- {
- sum += zone[z];
- count++;
- }
- else
- {
- sum = letters + zone[z];
- count++;
- }
- }
- index = z;
- if (sum < 0)
- {
- break;
- }
- }
- if (sum >= 0)
- {
- Console.WriteLine("{0} - fuel left {1:f2}", driveName[i], sum);
- }
- if (sum <= 0)
- {
- Console.WriteLine($"{driveName[i]} - reached {index}");
- }
- countName++;
- if (countName >= driveName.Length)
- {
- return;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment