#include "closing.h"
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define vi vector<int>
#define ll long long
#define ff first
#define ss second
using namespace std;
const int MAX=2e5+5;
vector<pair<int,int>> v[MAX];
ll maxi=0;
int D[MAX];
int R[MAX];
void dfs(int u,int p){
for(auto it:v[u]){
if(it.ff==p) continue;
D[it.ff]=D[u]+it.ss;
dfs(it.ff,u);
}
}
int max_score(int n,int x,int y, ll k,vi u,vi l, vi w){
for(int i=0;i<n-1;i++){
v[u[i]].push_back({l[i],w[i]});
v[l[i]].push_back({u[i],w[i]});
}
maxi=k;
D[x]=0;
dfs(x,-1);
for(int i=0;i<n;i++){
R[i]=D[i];
}
D[y]=0;
dfs(y,-1);
for(int i=0;i<n;i++){
R[i]=min(D[i],R[i]);
///cout<<R[i]<<" ";
}
sort(R,R+n);
ll awa=0;
int ans=0;
for(int i=0;i<n;i++){
if(awa+R[i]<=k){
awa+=R[i];
ans++;
}
else break;
}
for(int i=0;i<n;i++){
v[i].clear();
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
6488 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 |
81 ms |
24404 KB |
1st lines differ - on the 1st token, expected: '451', found: '200000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4956 KB |
Output is correct |
2 |
Incorrect |
2 ms |
5140 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 |
2 ms |
4956 KB |
Output is correct |
2 |
Incorrect |
2 ms |
5140 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 |
2 ms |
4956 KB |
Output is correct |
2 |
Incorrect |
2 ms |
5140 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 |
6488 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 |
6488 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 |
6488 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 |
6488 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 |
6488 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |