제출 #917203

#제출 시각아이디문제언어결과실행 시간메모리
917203zyq181Truck Driver (IOI23_deliveries)C++17
0 / 100
2142 ms2097152 KiB
#include "deliveries.h" #include <bits/stdc++.h> using namespace std; int N; vector<pair<int, int> > adjList[1010]; int paredge[1010]; int sbtree[1010]; int tot; int ans; int w[1010]; void dfs(int n, int p = -1){ sbtree[n]+=w[n]; for(auto it: adjList[n]){ int x, y; x = it.first; y = it.second; paredge[x] = y; dfs(x, n); sbtree[n] += sbtree[x]; } } void init(int NN, std::vector<int> U, std::vector<int> V, std::vector<int> T, std::vector<int> W) { N = NN; for(int a=0; a<N-1; a++){ adjList[U[a]].push_back({V[a], T[a]}); adjList[V[a]].push_back({U[a], T[a]}); } W[0]++; for(int a=0; a<N; a++){ w[a] = W[a]; tot += W[a]; } return; } long long max_time(int S, int X) { for(int a=0; a<N; a++) sbtree[a] = 0; ans = 0; tot -= w[S]; w[S] = X; if(S == 0) w[0]++; tot += w[S]; dfs(0); for(int a=1; a<N; a++){ if(tot/2 < sbtree[a]){ ans += 2 * (tot - sbtree[a]) * paredge[a]; } else{ ans += 2 * sbtree[a] * paredge[a]; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...