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. 22.allegro中PCB打印设置[原创]

    1. -- 2. 3. 4. ----

  2. Hibernate4.2.2使用Annotation配置

    1.在hibernate官网下载hibernate-release-4.2.2.Final.zip并解压 2.新建一个java project工程(20130619_Hibernate4.2.2_An ...

  3. uva580Critical Mass

    递推.   用f[i]代表i个盒子的放法,设g[i]=2^n-f[i],代表i个盒子不满足条件的放法. 枚举第一个U所在的位置j.则方法有g[j-2]*(2^(i-j-2))种,j-1必须是L. 所以 ...

  4. 在Windows下利用php自带的mail函数发邮件

    这几天看<Head First PHP & MySQL>,里面有发邮件的例子是用系统自带的mail函数发送的,自己照书上写的试了一直不成功,后来终于在网上找到解决方案,现在总结下. ...

  5. HDU 4635 Strongly connected (强连通分量)

    题意 给定一个N个点M条边的简单图,求最多能加几条边,使得这个图仍然不是一个强连通图. 思路 2013多校第四场1004题.和官方题解思路一样,就直接贴了~ 最终添加完边的图,肯定可以分成两个部X和Y ...

  6. python - os.path,路径相关操作

    python处理系统路径的相关操作: # -*- coding: utf-8 -*- import os # 属性 print '__file__: %s' % __file__ # 绝对路径(包含文 ...

  7. 02day2

    油滴扩展 [问题描述] 在一个长方形框子里,最多有 N(0≤N≤6)个相异的点.在其中任何-个点上放一个很小的油滴,那么这个油滴会一直扩展,直到接触到其他油滴或者框子的边界.必须等一个油滴扩展完毕才能 ...

  8. Oracle 课程四之索引

    课程目标 完成本课程的学习后,您应该能够: 理解b*tree索引的结构与特征 了解聚簇因子的产生原因 理解分区索引与全局索引的区别及场景 掌握组合索引的高效设计 位图索引的适用场景 全文索引的适用场景 ...

  9. WEXT driver的执行过程实现(iwpriv部分/softapcontroller)

    之前在看wifi driver源代码时一直有一个疑惑就是net dev的wireless_handlers中(WEXT类型的接口)提供两个iw_handler接口,怎么知道上层是调用的是private ...

  10. POJ 2421 Constructing Roads

    题意:要在n个城市之间建造公路,使城市之间能互相联通,告诉每个城市之间建公路的费用,和已经建好的公路,求最小费用. 解法:最小生成树.先把已经建好的边加进去再跑kruskal或者prim什么的. 代码 ...