Tram
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard outputLinear Kingdom has exactly one tram line. It has n stops, numbered from 1 to n in the order of tram’s movement. At the i-th stop ai passengers exit the tram, while bi passengers enter it. The tram is empty before it arrives at the first stop. Also, when the tram arrives at the last stop, all passengers exit so that it becomes empty.
Your task is to calculate the tram’s minimum capacity such that the number of people inside the tram at any time never exceeds this capacity. Note that at each stop all exiting passengers exit before any entering passenger enters the tram.
Input
The first line contains a single number n (2 ≤ n ≤ 1000) — the number of the tram’s stops.
Then n lin
Problem--116A--Codeforces--Tram
最新推荐文章于 2021-04-02 08:57:04 发布
该问题要求计算一条有n个停靠站的电车的最小容量,使得在任何时候车内的乘客数不超过这个容量。每个停靠站有乘客下车和上车,且在最后一个站所有乘客都会下车。输入包含停靠站数量及每个站的上下车人数,输出满足条件的最小电车容量。
摘要由CSDN通过智能技术生成