#include using namespace std; int main(){ int n; cin>>n; vector size(n); vector> edge(n); vector indeg(n); //V+E for (int i=0,d; i>size[i]>>d; for (int j=0; j>x; --x; edge[i].push_back(x); ++indeg[x]; } ++indeg[i]; } vector by_size(n); for (int i=n; i--;) by_size[i]=i; //V log V sort(by_size.begin(),by_size.end(),[&size](int a,int b){return size[a]>=1){ int mid=(lef+rad); vector deps=indeg; vector todo; //V+E for (int i=0,j=0; i