#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define el '\n'
#define ff first
#define ss second
#define pii pair <ll, ll>
#define pb push_back
#define mkp make_pair
#define fr(i, l, r) for(ll i = l; i <= r; i++)
#define debug(x) \
{ cout << #x << " = " << x << el; }
template<class T, class S>
inline bool chmax(T &a, const S &b) {
return (a < b ? a = b, 1 : 0);
}
template<class T, class S>
inline bool chmin(T &a, const S &b) {
return (a > b ? a = b, 1 : 0);
}
const ll N = 2e5 + 10;
const ll M = 1e5 + 10;
const ll K = 400;
const ll INF = 1e18 + 10;
const ll inf = 1e9 + 10;
const ll LOG = 20;
const ll mod = 1000002022;
mt19937 rnd(time(0));
/*
1
4 0 3 37
0 1 18
1 2 1
2 3 19
*/
vector <pii> g[N];
ll d[2][N];
void dfs(int v, int p, int t) {
for(pii u : g[v]) {
if(u.ff == p) continue;
d[t][u.ff] = d[t][v] + u.ss;
dfs(u.ff, v, t);
}
}
int max_score(int N, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
fr(i, 0, N - 1)
g[i].clear();
fr(i, 0, N - 2) {
g[U[i]].pb({V[i], W[i]});
g[V[i]].pb({U[i], W[i]});
}
d[0][X] = 0; d[1][Y] = 0;
dfs(X, X, 0);
dfs(Y, Y, 1);
vector <ll> s;
for(int i = 0; i < N; i++)
s.pb(min(d[0][i], d[1][i]));
sort(s.begin(), s.end());
ll ans = 0;
for(int i = 0; i < N; i++) {
if(K >= s[i]) {
K -= s[i];
ans++;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
8028 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
97 ms |
30668 KB |
Output is correct |
2 |
Correct |
82 ms |
36860 KB |
Output is correct |
3 |
Correct |
50 ms |
10708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Incorrect |
2 ms |
8028 KB |
1st lines differ - on the 1st token, expected: '30', found: '17' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Incorrect |
2 ms |
8028 KB |
1st lines differ - on the 1st token, expected: '30', found: '17' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8028 KB |
Output is correct |
2 |
Incorrect |
2 ms |
8028 KB |
1st lines differ - on the 1st token, expected: '30', found: '17' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
8028 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
8028 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
8028 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
8028 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
8028 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |