#include <deliveries.h>
#include <iostream>
#include <vector>
#define maxn 100005
#define maxq 300005
#define INF 1000000010
#define endl '\n'
using namespace std;
int n;
int t[maxn];
long long c[maxn];
vector <pair <int , int> > v[maxn];
long long ans;
long long pom;
void dfs(int node , int parent = -1)
{
c[node] = t[node];
for(int i = 0; i < (int)v[node].size(); i++)
{
if(v[node][i].first == parent) continue;
dfs(v[node][i].first , node);
ans += v[node][i].second * min(c[v[node][i].first] , pom - c[v[node][i].first]);
c[node] += c[v[node][i].first];
}
}
void init(int N , vector <int> U , vector <int> V, vector <int> W, vector <int> T)
{
n = N;
for(int i = 0; i < (int)U.size(); i++) v[U[i]].push_back({V[i] , W[i]});
for(int i = 0; i < (int)V.size(); i++) v[V[i]].push_back({U[i] , W[i]});
for(int i = 0; i < n; i++) pom += t[i];
for(int i = 0; i < n; i++) t[i] = T[i];
}
long long max_time(int S , int X)
{
pom -= t[S];
t[S] = X;
pom += t[S];
ans = 0;
dfs(0);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
74 ms |
10576 KB |
3rd lines differ - on the 1st token, expected: '39049160', found: '-106753302' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2648 KB |
3rd lines differ - on the 1st token, expected: '1627540', found: '-745530' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
74 ms |
10576 KB |
3rd lines differ - on the 1st token, expected: '39049160', found: '-106753302' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
74 ms |
10576 KB |
3rd lines differ - on the 1st token, expected: '39049160', found: '-106753302' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
74 ms |
10576 KB |
3rd lines differ - on the 1st token, expected: '39049160', found: '-106753302' |
2 |
Halted |
0 ms |
0 KB |
- |