# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
468554 | idk321 | Chase (CEOI17_chase) | C++17 | 534 ms | 170300 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100005;
const int V = 101;
int p[N];
int n, v;
vector<int> adj[N];
ll dp[N][2][V];
void dfs(int node, int par) {
for (int next : adj[node]) {
if (next == par) continue;
dp[node][1][1] += p[next];
dfs(next, node);
}
for (int next : adj[node]) {
if (next == par) continue;
for (int i = 0; i <= v; i++) {
dp[node][0][i] = max(dp[node][0][i], dp[node][0][0] + dp[next][0][i]);
dp[node][0][i] = max(dp[node][0][i], dp[node][0][0] + dp[next][1][i]);
if (i != v) {
dp[node][1][i + 1] = max(dp[node][1][i + 1], dp[node][1][1] + dp[next][0][i]);
dp[node][1][i + 1] = max(dp[node][1][i + 1], dp[node][1][1] + dp[next][1][i]);
}
}
}
# | 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... |