#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
int const N=2e5+10;
vector<pair<int,int>>nei[N]={};
long long dis[2][N]={};
bool uni=0;
vector<pair<long long,int>>d[2];
void dfs(int u,int p=-1)
{
d[uni].push_back({dis[uni][u],u});
for (auto [i,w]:nei[u])
{
if (i==p)
continue;
dis[uni][i]=dis[uni][u]+w;
dfs(i,u);
}
}
int max_score(int N, int X, int Y, long long K, vector<int> U,vector<int> V, vector<int> W)
{
for (int i=0;i<N-1;i++)
{
nei[U[i]].push_back({V[i],W[i]});
nei[V[i]].push_back({U[i],W[i]});
}
dfs(X);
uni=1;
dfs(Y);
for (int i=0;i<2;i++)
sort(begin(d[i]),end(d[i]));
int i=0,j=0;
int cnt=0;
while (i<N&&j<N)
{
long long z=1e15;
if (i<N)
z=d[0][i].first;
if (j<N)
z=min(z,d[0][i].first);
if (z>K)
break;
else
K-=z;
if (i<N&&j<N)
{
if (d[0][i].first<d[1][j].first)
{
cnt++;i++;
}
else
{
cnt++;j++;
}
}
else if (i==N)
{
cnt++;
j++;
}
else
cnt++,i++;
}
return cnt;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1138 ms |
1564172 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
97 ms |
38336 KB |
1st lines differ - on the 1st token, expected: '451', found: '449' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '30', found: '24' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '30', found: '24' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '30', found: '24' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1138 ms |
1564172 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1138 ms |
1564172 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1138 ms |
1564172 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1138 ms |
1564172 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1138 ms |
1564172 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |