#include "closing.h"
#include <bits/stdc++.h>
#include <vector>
#define ll long long
#define ff first
#define ss second
using namespace std;
vector<pair<int,ll> > v[200001];
ll dis[2][200001],dist[200001];
void dfs(int x,int p,ll d,bool k){
dis[k][x]=min(dis[k][x],d);
for(pair<int,int> i:v[x]){
if(i.ff!=p)
dfs(i.ff,x,d+i.ss,k);
}
}
int max_score(int N, int X, int Y, long long K,
std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
for(int i=0;i<N;i++){
v[i].clear();
dis[0][i]=2*K+1;
dis[1][i]=2*K+1;
}
for(int i=0;i<N-1;i++){
v[U[i]].push_back({V[i],W[i]});
v[V[i]].push_back({U[i],W[i]});
}
dfs(X,-1,0,0);
dfs(Y,-1,0,1);
for(int i=0;i<N;i++){
dist[i]=min(dis[0][i],dis[1][i]);
}
sort(dist,dist+N);
ll k=0;
int ans=0;
for(int i=0;i<N;i++){
if(k+dist[i]<=K){
k+=dist[i];
ans++;
}
else break;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
9560 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
116 ms |
32520 KB |
Output is correct |
2 |
Correct |
115 ms |
37800 KB |
Output is correct |
3 |
Correct |
66 ms |
14676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
9564 KB |
Output is correct |
2 |
Incorrect |
2 ms |
9560 KB |
1st lines differ - on the 1st token, expected: '30', found: '17' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
9564 KB |
Output is correct |
2 |
Incorrect |
2 ms |
9560 KB |
1st lines differ - on the 1st token, expected: '30', found: '17' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
9564 KB |
Output is correct |
2 |
Incorrect |
2 ms |
9560 KB |
1st lines differ - on the 1st token, expected: '30', found: '17' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
9560 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
9560 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
9560 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
9560 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
9560 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |