# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
122555 | 2019-06-28T15:22:37 Z | sofhiasouza | Chase (CEOI17_chase) | C++14 | 223 ms | 56824 KB |
#include <bits/stdc++.h> #define pb push_back using namespace std; typedef long long int ll; const int maxn = 1e5+10; vector < int > grafo[maxn]; int n, v, vet[maxn]; ll soma[maxn], dp[maxn][110]; void dfs(int u, int pai) { for(int i = 0 ; i < grafo[u].size() ; i++) { int k = grafo[u][i]; if(k == pai) continue; dfs(k, u); for(int j = 1 ; j <= v ; j++) { dp[u][j] = max(dp[u][j], dp[k][j-1] + soma[k] - vet[u]); } } } int main() { cin >> n >> v; for(int i = 1 ; i <= n ; i++) cin >> vet[i]; for(int i = 0 ; i < n-1 ; i++) { int a, b; cin >> a >> b; grafo[a].pb(b); grafo[b].pb(a); } for(int i = 1 ; i <= n ; i++) { for(int j = 0 ; j < grafo[i].size() ; j++) { soma[i] += vet[grafo[i][j]]; } } grafo[0].pb(1); dfs(0, 0); cout << dp[0][v] << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 223 ms | 56824 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |