Problem--116A--Codeforces--Tram

该问题要求计算一条有n个停靠站的电车的最小容量,使得在任何时候车内的乘客数不超过这个容量。每个停靠站有乘客下车和上车,且在最后一个站所有乘客都会下车。输入包含停靠站数量及每个站的上下车人数,输出满足条件的最小电车容量。
摘要由CSDN通过智能技术生成

Tram
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output

Linear 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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值