//#include "closing.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
int max_score(int n, int X, int Y, long long K,std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
vector<vector<pair<ll,ll>>> cad(n+2);
for(int i=0; i<n-1; i++)
{
cad[U[i]].push_back({V[i],W[i]});
cad[V[i]].push_back({U[i],W[i]});
}
vector<vector<ll>> q(2,vector<ll>(n+2,1e17));
q[0][X]=0;
q[1][Y]=0;
vector<vector<ll>> v(2,vector<ll>(n+2,-1));
ll cont=0;
while(true)
{
pair<ll,pair<ll,ll>> a={1e17,{1e17,1e17}};
for(int i=0; i<n; i++)
{
if(v[0][i]==-1) a=min(a,{q[0][i]-max(0LL,v[1][i]),{i,0}});
if(v[1][i]==-1) a=min(a,{q[1][i]-max(0LL,v[0][i]),{i,1}});
}
if(a.y.y==1e17) break;
if(K>=a.x)
{
v[a.y.y][a.y.x]=q[a.y.y][a.y.x];
K-=a.x;
cont++;
for(auto i:cad[a.y.x])
{
q[a.y.y][i.x]=q[a.y.y][a.y.x]+i.y;
}
}
}
return cont;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1035 ms |
27960 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1026 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1026 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1026 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |