← 返回 amazon 的题目列表Location Of Data After Transfers
类型:online_judge
amazon
Given a list of data transfer commands, with data starting at position 0. Each command contains three integers: start point, endpoint, and amount of data. Implement a function to compute the final position of the data after executing all the commands. The requirements are:
If the command's start point is equal to the current position, the data transfers to the endpoint.
Input consists of a list of commands, each command being a tuple (start, end, amount).
Input
n: number of commands
A list of commands, each being a tuple (start, end, amount)
Output
An integer representing the final position of the data.
Example
Input:
n = 3
tasks = [(0, 1, 10), (1, 2, 5), (2, 3, 5)]
Output:
3
Example
Input
3
0 1 10
1 2 5
2 3 5