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. WCF-学习笔记概述之计算服务(1)

    关于WCF的介绍,在此不再赘述,其他地方应有尽有.直接开始实例,第一个实例以一个简单的计算服务为例,本人是学习了蒋金楠的<WCF全面解析>. 1.构建解决方案 Interface:用于定义 ...

  2. 加密解密(10)常见HASH算法:MD5(128bit),SHA1(160bit)

  3. android动画坐标定义

    这段时间一直在忙Android的项目,总算抽出点时间休息一下,准备把一些项目用到的Android经验分享一下. 在Android开发过程中,经常会碰到Activity之间的切换效果的问题,下面介绍一下 ...

  4. UVa 10868 (物理) Bungee Jumping

    题意: 有个人在蹦极,给出悬崖的高度,绳子的长度,弹簧绳的胡克系数 以及 人的质量. 判断人是否能够着地,能的话是否能安全着地.所谓安全着地就是到达地面的速度不超过10m/s. 分析: 学过一点高中物 ...

  5. Struts2配置

    1.      设定server a)      window– preferences – myeclipse – servers – tomcat – 6.x b)      选择tomcat h ...

  6. 使用Spring时遇到的bug及解决

    1.myeclipse中Spring 不给提示 解决:(1)window – preferences – myeclipse – files and editors – xml – xml catal ...

  7. highcharts 柱状图动态设置数据应用实例

    <div id="container" style="min-width:700px;height:400px"></div> #jav ...

  8. H.264中NALU、RBSP、SODB的关系 (弄清码流结构)

    NALU:Coded H.264 data is stored or transmitted as a series of packets known as NetworkAbstraction La ...

  9. Oracle 手工清除回滚段的几种方法

    关于回滚段的问题,之前也小整理过一个,参考: Current online Redo 和 Undo 损坏的处理方法 http://blog.csdn.net/tianlesoftware/articl ...

  10. JAVA JDK1.5-1.9新特性

    1.51.自动装箱与拆箱:2.枚举(常用来设计单例模式)3.静态导入4.可变参数5.内省 1.61.Web服务元数据2.脚本语言支持3.JTable的排序和过滤4.更简单,更强大的JAX-WS5.轻量 ...