标签归档:树链剖分

[codeforces 733F] Drivers Dissatisfaction

Description

In one kingdom there are n cities and m two-way roads. Each road connects a pair of cities, and for each road we know the level of drivers dissatisfaction — the value wi.

For each road we know the value ci — how many lamziks we should spend to reduce the level of dissatisfaction with this road by one. Thus, to reduce the dissatisfaction with the i-th road by k, we should spend k·ci lamziks. And it is allowed for the dissatisfaction to become zero or even negative.

In accordance with the king's order, we need to choose n - 1 roads and make them the main roads. An important condition must hold: it should be possible to travel from any city to any other by the main roads.

The road ministry has a budget of S lamziks for the reform. The ministry is going to spend this budget for repair of some roads (to reduce the dissatisfaction with them), and then to choose the n - 1 main roads.

Help to spend the budget in such a way and then to choose the main roads so that the total dissatisfaction with the main roads will be as small as possible. The dissatisfaction with some roads can become negative. It is not necessary to spend whole budget S.

It is guaranteed that it is possible to travel from any city to any other using existing roads. Each road in the kingdom is a two-way road.

继续阅读

bzoj-USACO除草计划A

我已经做了30/30


继续阅读

CodeForces Round#359 Div.2 Solution

这场比赛现场我只做出了两题(果然还是太弱)

太久没碰代码导致码力下降以至于C题这种简单题不会做

D题知识迁移能力太弱,明明知道重心合并一定在路上= =却不敢写

QQ图片20160623113150下次在努力。。

继续阅读