Submission #388969

#TimeUsernameProblemLanguageResultExecution timeMemory
388969mosiashvililukaFireworks (APIO16_fireworks)C++14
7 / 100
1 ms332 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...