#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1000000000000000000LL;
ll n, m, q, k, x, y, a, b, c, d;
map<ll, ll> G[200000];
void dfs(ll x, vector<ll> &dist, ll d) {
dist[x] = d;
for (auto i : G[x]) {
if (dist[i.first] == INF) {
dfs(i.first, dist, d + i.second);
}
}
}
int max_score(int N, int X, int Y, long long K, vector<int> U, vector<int> V, vector<int> W) {
n = N;
x = X;
y = Y;
k = K;
for (auto i = 0; i < n - 1; i++) {
G[U[i]][V[i]] = W[i];
G[V[i]][U[i]] = W[i];
}
vector<ll> dist1(n, INF), dist2(n, INF);
dfs(x, dist1, 0);
dfs(y, dist2, 0);
vector<ll> vec;
for (int i = 0; i < n; i++) {
// cout << dist1[i] << ' ';
vec.push_back(dist1[i]);
}
// cout << '\n';
for (int i = 0; i < n; i++) {
vec.push_back(dist2[i]);
}
sort(vec.begin(), vec.end());
ll cnt = 0;
for (auto i : vec) {
// cout << i << '\n';
if (k >= i) {
cnt++;
k -= i;
}
else {
break;
}
}
return cnt;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
9820 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 |
121 ms |
54208 KB |
Output is correct |
2 |
Correct |
125 ms |
59328 KB |
Output is correct |
3 |
Execution timed out |
1028 ms |
31272 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
9828 KB |
Output is correct |
2 |
Incorrect |
1 ms |
9820 KB |
1st lines differ - on the 1st token, expected: '30', found: '24' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
9828 KB |
Output is correct |
2 |
Incorrect |
1 ms |
9820 KB |
1st lines differ - on the 1st token, expected: '30', found: '24' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
9828 KB |
Output is correct |
2 |
Incorrect |
1 ms |
9820 KB |
1st lines differ - on the 1st token, expected: '30', found: '24' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
9820 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 |
9820 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 |
9820 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 |
9820 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 |
9820 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |