题目描述:E. Restorer Distance
time limit per test 1 second
memory limit per test 256 megabytes
You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to hi, the height is measured in number of bricks. After the restoration all the N pillars should have equal heights.
You are allowed the following operations:
put a brick on top of one pillar, the cost of this operation is A;remove a brick from the top of one non-empty pillar, the cost of this operation is R;move a brick from the top of one non-empty pillar to the top of another pillar, the cost of this operation is M.You cannot create additional pillars or ignore some of pre-existing pillars even if their height becomes 0.
What is the minimal total cost of restoration, in other words, what is the minimal total cost to make all the pillars of equal height?
InputThe first line of input contains four integers N, A, R, M (1≤N≤105, 0≤A,R,M≤104) — the number of pillars and the costs of operations.
The second line contains N integers hi (0≤hi≤109) — initial heights of pillars.
OutputPrint one integer — the minimal cost of restoration.
阅读全文
题目描述:
给定一个圆,圆上有2N个互不重叠的点。每次操作随机选择两个先前未选择过的点连一条弦,共连成N条弦,求所有弦不交的概率。
输入描述:一行,只有一个整数N(1≤N≤10^7)。
输出描述:一行,即答案。答案应以模10 ^ 9+7的形式输出。正式的说,令M=10 ^ 9+7,答案可以表示为最简分数p/q的形式,其中p和q为整数且q与M互质。输出整数x满足 0≤x<M且 x⋅q ≡ p(mod M)。
阅读全文
题目描述Compute 有一棵 n 个点,编号分别为 1∼n 的树,其中 s 号点为根。Compute 在树上养了很多松鼠,在第 i 个点上住了 ai个松鼠。
因为某些缘故,它们开始同时向根节点移动,但它们相当不安分,如果在同一个节点上,它们就会打起来,简单地来说以下事件会依序发生:
·如果一个节点上有 2 只或 2 只以上的松鼠,他们会打架,然后这个节点上松鼠的数量会减少 1;
·根节点的所有松鼠移动到地面,位于地面上的松鼠不会再打架;
·所有松鼠同时朝它们的父节点移动。
所有事件各自都在一瞬间完成,直至树上没有松鼠。
现在 Compute 想知道最终有多少只松鼠到达了地面。
阅读全文
题目描述:E. Kaavi and Magic Spell
time limit per test 2 seconds
memory limit per test 512 megabytes
Kaavi, the mysterious fortune teller, deeply believes that one’s fate is inevitable and unavoidable. Of course, she makes her living by predicting others’ future. While doing divination, Kaavi believes that magic spells can provide great power for her to see the future.
阅读全文
最近一个月基本处在只偶尔打下contest不刷题的状态,结果就是把把拉胯
于是rating
这还是幸亏本场unrated了。让人不禁感叹这就是努力型选手吗,真是有够好笑的呢
痛定思痛,为了督促自己不要疏于练习,定个小目标,以后把每次contest最后做不出来(或者很勉强做出来)的题自己再好好理解总结一下(看难度和题数尽量做到Div.2的D或E题,1900-2200的),参考内容包括但不仅限于出题人给出的tutorial和别人的ac代码以及其他非官方的题解。
阅读全文