C++Advanced-Stacks and Queues - Exercise, Truck Tour
Suppose there is a circle. There are N petrol pumps on that circle. Petrol pumps are numbered 0 to (N−1) (both inclusive). You have two pieces of information corresponding to each of the petrol pump: (1) the amount of petrol that particular petrol pump will give, and (2) the distance from that petrol pump to the next petrol pump.
. You can start the tour at any of the petrol pumps. Calculate the first point from where the truck will be able to complete the circle. Consider that the truck will stop at each of the petrol pumps. The truck will move one kilometer for each liter of the petrol.
Input
The first line will contain the value of N
The next N lines will contain a pair of integers each, i.e. the amount of petrol that petrol pump will give and the distance between that petrol pump and the next petrol pump
Output
An integer which will be the smallest index of the petrol pump from which we can start the tour
Constraints
1 ≤ N ≤ 1000001
1 ≤ Amount of petrol, Distance ≤ 1000000000
Examples
Input Output
3
1 5
10 3
3 4 1
Input Output
8
10 1
10 1
10 1
6 6
6 6
6 15
10 5
6 12 0
Нулевите тестове минават, но другите не. Някой, ако желае, може ли да ми помогне с логиката
https://pastebin.com/xCN7PYUP
Благодаря за насоките! Пробвах да я реша с опашка, но станаха по-зле нещата. Получавам time limit на първите три теста и грешка на последните два. Явно толкова си мога.
https://pastebin.com/L9B4sGXm
Чети входа в queue<vector<int>>, а не във vector<string>. Tака ще можеш после при обработката да добавиш вектора за поредната помпа отзад, като го махнеш отпред.