Gym 100507C Zhenya moves from parents (线段树)
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.
- The date when it took place
- 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
线段树每个结点维护两个值,分别是这个区间的 负债 和 余钱. 按时间顺序从前往后看的时候,显然负债是单调不减的. 按时间顺序从后往前看的时候,显然余钱也是单调不减的,因为之前如果有余钱,可能会增加现在 ... 题意:儿子身无分文出去玩,只带了一张他爸的信用卡,当他自己现金不足的时候就会用信用卡支付,然后儿子还会挣钱,挣到的钱都是现金,也就是说他如果有现金就会先花现金,但是有了现金他不会还信用卡的钱.他每花一 ... Zhenya moves from parents Time limit: 1.0 secondMemory limit: 64 MB Zhenya moved from his parents’ h ... 2014. Zhenya moves from parents Time limit: 1.0 secondMemory limit: 64 MB Zhenya moved from his pare ... Zhenya moved from his parents' home to study in other city. He didn't take any cash with him, he onl ... Zhenya moves from the dormitory 题目链接: http://acm.hust.edu.cn/vjudge/contest/126546#problem/D Descrip ... 传送门 题意: 庭院中有 n 个围栏,每个围栏上都被涂上了不同的颜色(数字表示): 有 m 条指令,每条指令给出一个整数 x ,你要做的就是将区间[ x第一次出现的位置 , x最后出现的位置 ]中的围 ... 题面传送门 题意: 有一个 \(10^6\times 10^6\) 的地图.其中 \(m\) 个位置上有花,\(f\) 个矩形外围用栅栏围了起来.保证 \(f\) 个矩形两两之间没有公共点. \(q\ ... [题目大意] 有n只猴子坐在树上,m个笑话. 给出每个讲这个笑话的猴子的编号,笑话的编号,和笑话的影响半径. 如果一个树上的猴子听了没听过的笑话,会掉到树下.如果听过并且在树下,就会爬到树上. 问最后 ... VC,C++ Builder和lcc三个编译器 间枚举类型enum长度的情况. 各种C编译器默认的字节对齐数不一致,要写通用的代码,经常就是使用 #pragma pack(1) ... #pragma ... 由于代码有点多,所以就分开写了,注释还算详细,方便学习 Activity package com.lmw.android.test; import android.app.Activity; im ... Python 学习笔记[dict的操作方法] Python中dict详解 http://www.tuicool.com/articles/ZJfeAzi 由于 appspot.com被墙,一般调试不成功. 随着智能手机的普及,移动设备的浏览器功能越来越强大,我们用手机上网时 ... from:http://wenku.baidu.com/link?url=hYQHJcAWUIS-8C7nSBbf-8lGagYGXKb5msVwQKWyXFAcPLU5gR4BKOVLrFOw4bX ... 原文网址:http://blog.it985.com/9683.html 在使用tableView的时候,如果cell的布局过于复杂,通过代码搭建的话不够直观.并且要不停的调整位置,字体什么的.这时, ... 原因分析解决及如何避免(PowerCenter 8.6.1) 前几天同事安装了个PowerCenter8.6.1做测试,出去了几天回来后Administration Console无法登入了.同事用的 ... SQL 在突然停电或者非正常关机下,可能会出现日期文件错误,导致数据库不正常.恢复数据库方法如下 1.数据库服务停掉 将数据库文件备份 例如数据库名为 DTMS 则将 DTMS.mdf 备份出来. 2 ... 题意: 给你一个括号序列(有中小括号),求出以给定序列为子序列的最小合法括号序列. 分析: 非常经典,以前做过相似一道题,用区间dp,但怎么把这个序列求出来没想出来. dp[i][j]表示区间i-j是 ... 第一部分 Selenium简介 1.Selenium 组建 1.1 Selenium-IDE Selenium-IDC是开发Selenium测试案例的集成开发环境.它像FireFox插件一样的工作,支 ...
The first line contains an integer
Gym 100507C Zhenya moves from parents (线段树)的更多相关文章
随机推荐