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.Threading.Tasks;
- namespace Endurance_Rally
- {
- class Participant
- {
- public string Name { get; set; }
- public string Position { get; set; }
- public double ValuePosition { get; set; }
- }
- class Program
- {
- static void Main()
- {
- string[] name = Console.ReadLine()
- .Split(new char[] { ' '},
- StringSplitOptions.RemoveEmptyEntries);
- double[] zones = Console.ReadLine()
- .Trim()
- .Split(new char[] { ' '},
- StringSplitOptions.RemoveEmptyEntries)
- .Select(double.Parse)
- .ToArray();
- int[] checkPoint = Console.ReadLine()
- .Trim()
- .Split(new char[] { ' '},
- StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- List<Participant> participants = new List<Participant>();
- bool check = false;
- double[] fuel = new double[name.Length];
- for (int i = 0; i < name.Length; i++)
- {
- int codeName = name[i][0];
- fuel[i] = codeName;
- }
- for (int i = 0; i < zones.Length; i++)
- {
- zones[i] *= -1.0;
- }
- for (int i = 0; i < checkPoint.Length; i++)
- {
- if (checkPoint[i] >= 0 && checkPoint[i] < zones.Length)
- {
- zones[checkPoint[i]] *= -1.0;
- }
- }
- for (int i = 0; i < fuel.Length; i++)
- {
- Participant person = new Participant();
- for (int j = 0; j < zones.Length; j++)
- {
- fuel[i] += zones[j];
- if ((fuel[i]<=0))
- {
- person.Name = name[i];
- person.Position = "reached";
- person.ValuePosition = (double)j;
- participants.Add(person);
- check = true;
- break;
- }
- }
- if (!check)
- {
- person.Name = name[i];
- person.Position = "fuel left";
- person.ValuePosition = fuel[i];
- participants.Add(person);
- }
- check = false;
- }
- foreach (var result in participants)
- {
- Console.Write("{0} - {1} ",
- result.Name,result.Position);
- if (result.Position== "reached")
- {
- Console.WriteLine("{0}",result.ValuePosition);
- }
- else
- {
- Console.WriteLine("{0:F2}",result.ValuePosition);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement