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 o…
线段树每个结点维护两个值,分别是这个区间的 负债 和 余钱. 按时间顺序从前往后看的时候,显然负债是单调不减的. 按时间顺序从后往前看的时候,显然余钱也是单调不减的,因为之前如果有余钱,可能会增加现在的余钱,但之前的负债不会减少现在的余钱. 所以线段树的区间合并这样做: 当前区间的负债 = 左区间的负债 + max(右区间的负债 - 左区间的余钱,0): 当前区间的余钱 = 右区间的余钱 + max(左区间的余钱 - 右区间的负债,0): 最后答案就是整个区间的负债. 代码自行脑补.…
Zhenya moves from parents Time limit: 1.0 secondMemory limit: 64 MB 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 studie…
2014. Zhenya moves from parents Time limit: 1.0 secondMemory limit: 64 MB 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…
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 a…
Zhenya moves from the dormitory 题目链接: http://acm.hust.edu.cn/vjudge/contest/126546#problem/D Description After moving from his parents' place Zhenya has been living in the University dormitory for a month. However, he got pretty tired of the curfew t…
题意:儿子身无分文出去玩,只带了一张他爸的信用卡,当他自己现金不足的时候就会用信用卡支付,然后儿子还会挣钱,挣到的钱都是现金,也就是说他如果有现金就会先花现金,但是有了现金他不会还信用卡的钱.他每花一次钱和挣一次钱都会给他爸发一条短信,告诉他挣/花的钱和时间,但是给出的短信顺序时间可能不是按顺序来的,然后他爸要根据现有的短信信息推测信用卡现在的负债是多少. 解法: 因为挣的钱或花的钱都只影响后面时间的负债,时间离散,每加入一个值,都更新这个pos到n的所有值,然后整个时间最小的值就是答案.结果与…
Flipping Parentheses 题目连接: http://codeforces.com/gym/100803/attachments Description A string consisting only of parentheses '(' and ')' is called balanced if it is one of the following. • A string "()" is balanced. • Concatenation of two balance…
Intervals 题目连接: http://codeforces.com/gym/100231/attachments Description 给你n个区间,告诉你每个区间内都有ci个数 然后你需要找一个最小的点集,使得满足这n个区间的条件 Input n 然后li,ri,ci Output 输出最小点集大小 Sample Input 5 3 7 3 8 10 3 6 8 1 1 3 1 10 11 1 Sample Output 6 Hint 题意 题解: 线段树+二分+贪心 首先我们贪心一…
F. Ilya Muromets Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/problem/F Description I Ilya Muromets is a legendary bogatyr. Right now he is struggling against Zmej Gorynych, a dragon with n heads numbered from 1 to nf…