Zhenya moves from parents

题目链接:

http://acm.hust.edu.cn/vjudge/contest/126546#problem/C

Description


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

Gym 100507C Zhenya moves from parents (线段树)的更多相关文章

  1. 【线段树】Gym - 100507C - Zhenya moves from parents

    线段树每个结点维护两个值,分别是这个区间的 负债 和 余钱. 按时间顺序从前往后看的时候,显然负债是单调不减的. 按时间顺序从后往前看的时候,显然余钱也是单调不减的,因为之前如果有余钱,可能会增加现在 ...

  2. URAL 2014 Zhenya moves from parents --线段树

    题意:儿子身无分文出去玩,只带了一张他爸的信用卡,当他自己现金不足的时候就会用信用卡支付,然后儿子还会挣钱,挣到的钱都是现金,也就是说他如果有现金就会先花现金,但是有了现金他不会还信用卡的钱.他每花一 ...

  3. ural2014 Zhenya moves from parents

    Zhenya moves from parents Time limit: 1.0 secondMemory limit: 64 MB Zhenya moved from his parents’ h ...

  4. ural 2014 Zhenya moves from parents

    2014. Zhenya moves from parents Time limit: 1.0 secondMemory limit: 64 MB Zhenya moved from his pare ...

  5. zhenya moves from parents

    Zhenya moved from his parents' home to study in other city. He didn't take any cash with him, he onl ...

  6. Gym 100507D Zhenya moves from the dormitory (模拟)

    Zhenya moves from the dormitory 题目链接: http://acm.hust.edu.cn/vjudge/contest/126546#problem/D Descrip ...

  7. Gym 101911E "Painting the Fence"(线段树区间更新+双端队列)

    传送门 题意: 庭院中有 n 个围栏,每个围栏上都被涂上了不同的颜色(数字表示): 有 m 条指令,每条指令给出一个整数 x ,你要做的就是将区间[ x第一次出现的位置 , x最后出现的位置 ]中的围 ...

  8. Codeforces Gym 101480C - Cow Confinement(扫描线+线段树)

    题面传送门 题意: 有一个 \(10^6\times 10^6\) 的地图.其中 \(m\) 个位置上有花,\(f\) 个矩形外围用栅栏围了起来.保证 \(f\) 个矩形两两之间没有公共点. \(q\ ...

  9. 组队赛Day1第一场 GYM 101350 F. Monkeying Around(线段树)

    [题目大意] 有n只猴子坐在树上,m个笑话. 给出每个讲这个笑话的猴子的编号,笑话的编号,和笑话的影响半径. 如果一个树上的猴子听了没听过的笑话,会掉到树下.如果听过并且在树下,就会爬到树上. 问最后 ...

随机推荐

  1. Linux/Centos下清理内存和Cache方法

    Linux/Centos下释放内存和缓存方法 $ free -m 运行sync将dirty的内容写回硬盘$ sync 通过修改proc系统的drop_caches清理free的cache$ echo ...

  2. mysql 行列动态转换(列联表,交叉表)

    mysql 行列动态转换(列联表,交叉表) (1)动态,适用于列不确定情况 create table table_name( id int primary key, col1 char(2), col ...

  3. trackr: An AngularJS app with a Java 8 backend – Part III

    这是最后我们对trackr系列的一部分.在过去的两的博文中,我们已经向您展示我们使用的工具和框架构建后端和前端.如果你错过了前面的帖子现在你可能会想读他们赶上来. Part I – The Backe ...

  4. ViewPager介绍和使用说明

    1   ViewPager实现的功能 和实际运行的效果图示意 ViewPager类提供了多界面切换的新效果.新效果有如下特征: [1] 当前显示一组界面中的其中一个界面. [2] 当用户通过左右滑动界 ...

  5. 宏buf_pool_t

    typedef struct buf_pool_struct buf_pool_t; struct buf_pool_struct{ /** @name General fields */ /* @{ ...

  6. JS闭包的两个使用方向

    直接上代码,备用,详见注释 <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="serve ...

  7. LA 3704 (矩阵快速幂 循环矩阵) Cellular Automaton

    将这n个格子看做一个向量,每次操作都是一次线性组合,即vn+1 = Avn,所求答案为Akv0 A是一个n*n的矩阵,比如当n=5,d=1的时候: 不难发现,A是个循环矩阵,也就是将某一行所有元素统一 ...

  8. 【转】如何在IOS中使用3D UI - CALayer的透视投影

    原文网址:http://www.tairan.com/archives/2041/ 例子代码可以在 http://www.tairan.com/thread-3607-1-1.html 下载 iOS的 ...

  9. request的用法

    Request从几个集合取数据是有顺序的,从前到后的顺序依次是 QueryString,Form,最后是ServerVariables.Request对象按照这样的顺序依次搜索这几个集合中的变量,如果 ...

  10. chrome console js多行输入

    一直以来,Chrome控制台都缺少象IE调试台那样的多行执行模式.  今天意外发现Chrome其实也支持多行模式.默认在Chrome控制台上输入回车后会执行该命令,只需要通过输入Shift+Enter ...