Bzoj4027 [heoi2015]兔子与樱花

Posted by yjjr's blog on February 6, 2018

Description

Input

Output

一行一个整数，表示最多能删除多少节点。

Sample Input

10 4

0 2 2 2 4 1 0 4 1 1

3 6 2 3

1 9

1 8

1 1

0

0

2 7 4

0

1 5

0

Sample Output

4

HINT

Code

#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define mem(x,num) memset(x,num,sizeof x)
#define LL long long
using namespace std;
{
LL f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
const int maxn=2e6+6;
LL n,m,ans,c[maxn];
vector<LL>e[maxn];
inline bool cmp(int a,int b){return c[a]<c[b];}
void dfs(int x)
{
for(int i=0;i<e[x].size();i++)dfs(e[x][i]);
sort(e[x].begin(),e[x].end(),cmp);
c[x]+=e[x].size();
for(int i=0;i<e[x].size();i++){
int t=c[e[x][i]];
if(c[x]+t-1<=m){
c[x]+=t-1;
ans++;
}
else break;
}
}

int main()
{
}