# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
132152 | 2019-07-18T11:00:19 Z | Vardanyan | Chase (CEOI17_chase) | C++14 | 959 ms | 8632 KB |
#include <bits/stdc++.h> using namespace std; const int N = 100*1000+5; int d[N]; long long ans = 0; int qn; vector<int> g[N]; void dfs(int v,int p = -1,int hm = qn,long long now = 0){ if(hm == 0){ ans = max(ans,now); return; } for(int i = 0;i<g[v].size();i++){ int to = g[v][i]; if(to == p) continue; now+=d[to]; } for(int i = 0;i<g[v].size();i++){ int to = g[v][i]; if(to == p) continue; dfs(to,v,hm-1,now); } } int main(){ ios_base::sync_with_stdio(false); int n; cin>>n>>qn; for(int i = 1;i<=n;i++) cin>>d[i]; for(int i = 0;i<n-1;i++){ int x,y; cin>>x>>y; g[x].push_back(y); g[y].push_back(x); } for(int i = 1;i<=n;i++){ dfs(i); } cout<<ans<<endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Incorrect | 4 ms | 2680 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Incorrect | 4 ms | 2680 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 959 ms | 8632 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Incorrect | 4 ms | 2680 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |