把所有点拆成两个,将符合条件的两个点x,y连上边,流量为1,费用为-(x+y). 做一遍最小费用最大流,最后ans div 2即可. Program bzoj2661; ; ..] of longint; flag1,flag2:..] of boolean; a,c,i,j,x,y,t,s,sum:longint; b:..] of longint; pd:..] of boolean; d,ps:..] of longint; function gcd(x,y:longint):longin…