题意: 给出一棵树,每条边有一个容量. 有若干次询问:\(S \, T \, K \, A \, B\),求路径\(S \to T\)的最大流量. 有两种方法可以增大流量: 花费\(A\)可以新修一条管道,管道可以连接任意两个点,两个点之间可以有任意条管道连接,新修的管道容量为\(1\) 花费\(B\)可以使某条管道(包括新修的管道)的容量增加\(1\) 求在不超过预算\(K\)的情况下的最大流量. 分析: 注意到流量最大只有\(10^4\),所以我们可以直接在值域上建一棵主席树. 主席树区间维…
题意 链接:https://cn.vjudge.net/problem/HDU-4729 给你n个点,然你求两个点s和t之间的最大流.而且你有一定的钱k,可以进行两种操作 1.在任意连个点之间建立一个单位1的流,费用a 2.将原先的流扩大1个单位,费用b 思路 题目已经说了是一棵树,那么树上两点的最大流就是两点路径上的最小值.其实两种操作各一次对最大流的贡献是相等的.我们分类讨论: 如果a<=b,直接算第一种方案即可,直接给s.t连一条边,对答案的贡献是k/a. 如果a>b,分两种情况.如果k…
An Easy Problem for Elfness Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1148    Accepted Submission(s): 234 Problem Description Pfctgeorge is totally a tall rich and handsome guy. He plans t…
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove 题意:给出一个带边权的图.对于每一个询问(S , T , K , A , B),有两种操作,加一条单位边花费为A,将某条边流量扩展一个单位花费为B,在预算为K的情况下求S到T最大流的最大值. http://acm.hdu.edu.cn/showproblem.php?pid=4729 做法:如果A <= B,很明显只做添加边操作,而且只加在S -…
Problem Description Pfctgeorge is totally a tall rich and handsome guy. He plans to build a huge water transmission network that covers the whole southwest China. To save the fund, there will be exactly one path between two cities. Since the water ev…
其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到boundry,使得boundry * n_edge - sum_edge <= k/b, 或者建立s->t,然后不断extend s->t. /* 4729 */ #include <iostream> #include <sstream> #include <…
http://acm.hdu.edu.cn/showproblem.php?pid=5475 An easy problem Time Limit: 8000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 755 Accepted Submission(s): 431 Problem Description One day, a useless calculator was…
Just h-index Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others)Total Submission(s): 438    Accepted Submission(s): 203 Problem Description The h-index of an author is the largest h where he has at least h papers wit…
题目链接: http://poj.org/problem?id=2104 K-th Number Time Limit: 20000MSMemory Limit: 65536K 问题描述 You are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a new data…
题目大意:对于一个序列,每次询问区间[l,r]的第k大树. 分析: 主席树模板题 program kthtree; type point=record l,r,s:longint; end; var t:..*]of point; a,b,id,root:..]of longint; n,i,m,x,y,k,v,len:longint; procedure qsort(l,h:longint); var i,j,t,m:longint; begin i:=l; j:=h; m:=a[(i+j)…