//#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]=a.x;
//cout<<a.y.x;
K-=a.x;
cont++;
for(auto i:cad[a.y.x])
{
q[a.y.y][i.x]=a.x+i.y;
}
}
else break;
}
return cont;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
325 ms |
31380 KB |
Output is correct |
2 |
Correct |
521 ms |
31796 KB |
Output is correct |
3 |
Correct |
79 ms |
5456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
432 KB |
1st lines differ - on the 1st token, expected: '30', found: '40' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
432 KB |
1st lines differ - on the 1st token, expected: '30', found: '40' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
432 KB |
1st lines differ - on the 1st token, expected: '30', found: '40' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
432 KB |
1st lines differ - on the 1st token, expected: '30', found: '40' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
432 KB |
1st lines differ - on the 1st token, expected: '30', found: '40' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
432 KB |
1st lines differ - on the 1st token, expected: '30', found: '40' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
432 KB |
1st lines differ - on the 1st token, expected: '30', found: '40' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
432 KB |
1st lines differ - on the 1st token, expected: '30', found: '40' |
4 |
Halted |
0 ms |
0 KB |
- |