Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Advanced
- {
- class Program
- {
- static void Main(string[] args)
- {
- int numberOfPumps = int.Parse(Console.ReadLine());
- var pumpIndex = new Queue<int>();
- var fuel = 0;
- for (int i = 0; i < numberOfPumps; i++)
- {
- var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
- var pompCapacity = input[0];
- var distance = input[1];
- fuel += pompCapacity;
- if (fuel >= distance)
- {
- pumpIndex.Enqueue(i);
- fuel -= distance;
- }
- else
- {
- pumpIndex.Clear();
- fuel = 0;
- }
- }
- Console.WriteLine(pumpIndex.Min());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement