This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,dp[309][309],dep[309],E[309],EI;
vector <pair <long long, long long> > v[5009];
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a>>b;
for(i=2; i<=a; i++){
cin>>c>>d;
v[c].push_back(make_pair(i,d));
}
for(i=a+1; i<=a+b; i++){
cin>>c>>d;
v[c].push_back(make_pair(i,d));
EI++;
E[EI]=d;
}
if(a==1){
sort(E+1,E+EI+1);
c=E[EI/2+EI%2];
e=0;
for(i=1; i<=EI; i++){
e+=abs(c-E[i]);
}
cout<<e;
return 0;
}
//dfsst(1,0);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |