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
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

本文介绍了一个收支记录混乱的问题,即收支信息的信件送达顺序与实际发生顺序不符,导致难以准确计算信用卡债务。需要帮助一位父亲整理其儿子寄来的收支信件,并正确计算信用卡上的债务。

被折叠的 条评论
为什么被折叠?



