Gym100507C--Zhenya moves from parents(线段树+懒标记)

Problem C. Zhenya moves from parents
Time limit: 1 second
Memory limit: 64 megabytes
Zhenya moved from his parents’ home to study in other city. He didn’t take any cash with him, he only
took his father’s credit card with zero balance on it. Zhenya succeeds in studies at the University and
sometimes makes a little money on the side as a Maths tutor. As he makes his own money he spends only
it, and when it is over he uses the credit card. Every time he gets or spends money, he sends a letter to
his father, where he puts the following two things.
1. The date when it took place
2. The sum of earned or spent money
Every time receiving a letter from Zhenya, his father calculates the debt on the credit card at the moment.
But here a problem arises. The point is that Russian Post delivers letters in an order different to the one
they were sent in.
For example, in the first Zhenya’s letter the father read that on September 10 Zhenya spent one thousand
rubles. He thought that his son had used the credit card, and now the debt is one thousand rubles. However
the next day came a letter with the information that on September 9 Zhenya earned five hundred rubles.
It means that half of the money he spent on September 10 was his own, and the debt on the credit card
is just five hundred rubles.
Help Zhenya’s father with his account management.
Input
The first line contains an integer
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值