# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
805304 | Kerim | 경주 (Race) (IOI11_race) | C++17 | 347 ms | 122516 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "race.h"
#include "bits/stdc++.h"
#define ll long long
using namespace std;
typedef pair<int, int> pii;
const int N = 2e5+5;
const int INF = 1e9;
vector<pii> adj[N];
int K, answer;
int dp[N][105];
void dfs(int nd, int pr){
dp[nd][0] = 0;
for (int i = 1; i <= K; i++)
dp[nd][i] = INF;
for (auto [c, e]: adj[nd]){
if (c == pr)
continue;
dfs(c, nd);
//update answer
for (int w1 = 0; w1 + e <= K; w1++){
int w2 = K - e - w1;
answer = min(answer, dp[nd][w1] + dp[c][w2]+1);
}
//update dp
for (int p = 0; p+e <= K; p++)
dp[nd][p+e] = min(dp[nd][p+e],dp[c][p]+1);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |