Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using System.Globalization;
- namespace ExamPreparation2
- {
- public class Program
- {
- public static void Main()
- {
- bool end = false;
- var drivers = Console.ReadLine().Split().ToArray();
- var zones = Console.ReadLine().Split().Select(double.Parse).ToArray();
- var checkPoints = Console.ReadLine().Split().Select(double.Parse).ToArray();
- foreach (var driver in drivers)
- {
- double fuel = driver[0];
- for (int i = 0; i < zones.Length; i++)
- {
- var index = i;
- if(checkPoints.Contains(index))
- {
- foreach (var item in checkPoints)
- {
- if (index == item)
- {
- fuel += zones[i];
- }
- }
- }
- else
- {
- fuel -= zones[i];
- if (fuel <= 0)
- {
- end = true;
- Console.WriteLine("{0} - reached {1}",driver,i);
- break;
- }
- }
- }
- Console.WriteLine("{0} - fuel left {1:f2}",driver,fuel);
- if(end) break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement