#include "deliveries.h"
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
long long tot=0,ans=0;
vector<int> sz(N),w;
vector<pair<int,int>> adj[N];
void dfs(int k,int pa,int t){
sz[k]=w[k];
for(auto [j,c]:adj[k]){
if(j==pa)continue;
dfs(j,k,c);
sz[k]+=sz[j];
}
long long y=min(1ll*sz[k],tot-sz[k]);
ans+=y*t*2;
}
void init(int N, vector<int> U, vector<int> V, vector<int> T, vector<int> W) {
w=W;
for(int i=0;i<N-1;i++){
adj[U[i]].push_back({V[i],T[i]});
adj[V[i]].push_back({U[i],T[i]});
}
for(int i=0;i<N;i++){
tot+=w[i];
}
w[0]++;
tot++;
return;
}
long long max_time(int S, int X) {
ans=0;
X+=(S==0);
tot-=w[S];
w[S]=X;
tot+=X;
dfs(1,1,0);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
89 ms |
13316 KB |
Output is correct |
2 |
Correct |
72 ms |
12880 KB |
Output is correct |
3 |
Correct |
72 ms |
12928 KB |
Output is correct |
4 |
Correct |
71 ms |
12884 KB |
Output is correct |
5 |
Correct |
73 ms |
13132 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3160 KB |
Output is correct |
2 |
Correct |
6 ms |
3164 KB |
Output is correct |
3 |
Correct |
8 ms |
3164 KB |
Output is correct |
4 |
Correct |
9 ms |
3316 KB |
Output is correct |
5 |
Correct |
9 ms |
3164 KB |
Output is correct |
6 |
Correct |
10 ms |
3344 KB |
Output is correct |
7 |
Correct |
10 ms |
3416 KB |
Output is correct |
8 |
Correct |
10 ms |
3164 KB |
Output is correct |
9 |
Correct |
10 ms |
3348 KB |
Output is correct |
10 |
Correct |
10 ms |
3164 KB |
Output is correct |
11 |
Correct |
9 ms |
3212 KB |
Output is correct |
12 |
Correct |
9 ms |
3296 KB |
Output is correct |
13 |
Correct |
10 ms |
3416 KB |
Output is correct |
14 |
Correct |
12 ms |
3164 KB |
Output is correct |
15 |
Correct |
12 ms |
3164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
89 ms |
13316 KB |
Output is correct |
2 |
Correct |
72 ms |
12880 KB |
Output is correct |
3 |
Correct |
72 ms |
12928 KB |
Output is correct |
4 |
Correct |
71 ms |
12884 KB |
Output is correct |
5 |
Correct |
73 ms |
13132 KB |
Output is correct |
6 |
Correct |
1 ms |
3160 KB |
Output is correct |
7 |
Correct |
22 ms |
3344 KB |
Output is correct |
8 |
Correct |
2037 ms |
5052 KB |
Output is correct |
9 |
Execution timed out |
5563 ms |
18228 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
89 ms |
13316 KB |
Output is correct |
2 |
Correct |
72 ms |
12880 KB |
Output is correct |
3 |
Correct |
72 ms |
12928 KB |
Output is correct |
4 |
Correct |
71 ms |
12884 KB |
Output is correct |
5 |
Correct |
73 ms |
13132 KB |
Output is correct |
6 |
Correct |
1 ms |
3160 KB |
Output is correct |
7 |
Correct |
30 ms |
3412 KB |
Output is correct |
8 |
Correct |
2826 ms |
5756 KB |
Output is correct |
9 |
Execution timed out |
5524 ms |
25136 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
89 ms |
13316 KB |
Output is correct |
2 |
Correct |
72 ms |
12880 KB |
Output is correct |
3 |
Correct |
72 ms |
12928 KB |
Output is correct |
4 |
Correct |
71 ms |
12884 KB |
Output is correct |
5 |
Correct |
73 ms |
13132 KB |
Output is correct |
6 |
Correct |
2 ms |
3160 KB |
Output is correct |
7 |
Correct |
6 ms |
3164 KB |
Output is correct |
8 |
Correct |
8 ms |
3164 KB |
Output is correct |
9 |
Correct |
9 ms |
3316 KB |
Output is correct |
10 |
Correct |
9 ms |
3164 KB |
Output is correct |
11 |
Correct |
10 ms |
3344 KB |
Output is correct |
12 |
Correct |
10 ms |
3416 KB |
Output is correct |
13 |
Correct |
10 ms |
3164 KB |
Output is correct |
14 |
Correct |
10 ms |
3348 KB |
Output is correct |
15 |
Correct |
10 ms |
3164 KB |
Output is correct |
16 |
Correct |
9 ms |
3212 KB |
Output is correct |
17 |
Correct |
9 ms |
3296 KB |
Output is correct |
18 |
Correct |
10 ms |
3416 KB |
Output is correct |
19 |
Correct |
12 ms |
3164 KB |
Output is correct |
20 |
Correct |
12 ms |
3164 KB |
Output is correct |
21 |
Correct |
1 ms |
3160 KB |
Output is correct |
22 |
Correct |
22 ms |
3344 KB |
Output is correct |
23 |
Correct |
2037 ms |
5052 KB |
Output is correct |
24 |
Execution timed out |
5563 ms |
18228 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |