代码来源:
http://hi.baidu.com/chingfantsou/item/fb84b21438ac14e55f53b194
#include <cstdio>
#include <algorithm>
using namespace std;
int n;
int p[10001],d[10001];
int md;
int ans;
int h[10001];
struct pro
{
int p,d;
}pd[10001];
bool cmp(pro a,pro b) {return (a.p>b.p);}
inline int find(int x)
{//并查集查找 递归的路径压缩
if (h[x]==x) return x;
h[x]=find(h[x]);
return h[x];
}
int main()
{
while(scanf("%d",&n)==1)
{
ans=0;
md=-1;//......
阅读全文