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…
2015. Zhenya moves from the dormitory Time limit: 1.0 secondMemory limit: 64 MB 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 time and queues to the sho…
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…
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 time and queues to the shower room so he took a fancy for renting an apartment. It turned out not the easi…
线段树每个结点维护两个值,分别是这个区间的 负债 和 余钱. 按时间顺序从前往后看的时候,显然负债是单调不减的. 按时间顺序从后往前看的时候,显然余钱也是单调不减的,因为之前如果有余钱,可能会增加现在的余钱,但之前的负债不会减少现在的余钱. 所以线段树的区间合并这样做: 当前区间的负债 = 左区间的负债 + 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…
题意:儿子身无分文出去玩,只带了一张他爸的信用卡,当他自己现金不足的时候就会用信用卡支付,然后儿子还会挣钱,挣到的钱都是现金,也就是说他如果有现金就会先花现金,但是有了现金他不会还信用卡的钱.他每花一次钱和挣一次钱都会给他爸发一条短信,告诉他挣/花的钱和时间,但是给出的短信顺序时间可能不是按顺序来的,然后他爸要根据现有的短信信息推测信用卡现在的负债是多少. 解法: 因为挣的钱或花的钱都只影响后面时间的负债,时间离散,每加入一个值,都更新这个pos到n的所有值,然后整个时间最小的值就是答案.结果与…
题意:给定 n 个裁判,然后每个都一些题目,现在要从每一个按顺序去选出 k 个题,并且这 k 个要按不递减顺序,如果没有,就用50补充. 析:就按他说的来,直接模拟就好. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #…