#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mk make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
ll cost[2][3100];
vector<pair<ll,ll> > v[3400];
void go(int cr,ll ds,int pr,int f){
cost[f][cr]=ds;
for(auto u:v[cr]){
if(u.ff==pr)continue;
go(u.ff,ds+u.ss,cr,f);
}
}
ll dp[3010][6010];
int n;
ll solve(int cr,int rem){
if(rem==0)return 0;
if(cr>n){
return 2e18;
}
ll &ret=dp[cr][rem];
if(ret!=-1)return ret;
ret=3e18;
ret=min(ret,solve(cr+1,rem));
ret=min(ret,solve(cr+1,rem-1)+min(cost[0][cr],cost[1][cr]));
ret=min(ret,solve(cr+1,rem-2)+max(cost[0][cr],cost[1][cr]));
return ret;
}
int max_score(int N, int X, int Y, long long K,
std::vector<int> U, std::vector<int> V, std::vector<int> W){
n=N;
for(int i=0;i<N-1;i++){
v[U[i]].pb({V[i],W[i]});
v[V[i]].pb({U[i],W[i]});
}
go(X,0,0,0);
go(Y,0,0,1);
memset(dp,-1,sizeof dp);
int maxS=0;
for(int i=0;i<=n*2;i++){
if(solve(1,i)<=K){
maxS=i;
}
}
return maxS;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1153 ms |
2073992 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
55 ms |
11376 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
43 ms |
141884 KB |
1st lines differ - on the 1st token, expected: '3', found: '4' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
43 ms |
141884 KB |
1st lines differ - on the 1st token, expected: '3', found: '4' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
43 ms |
141884 KB |
1st lines differ - on the 1st token, expected: '3', found: '4' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1153 ms |
2073992 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1153 ms |
2073992 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1153 ms |
2073992 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1153 ms |
2073992 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1153 ms |
2073992 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |