# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
942059 |
2024-03-10T07:30:16 Z |
Darren0724 |
Chase (CEOI17_chase) |
C++17 |
|
4000 ms |
18004 KB |
#include <bits/stdc++.h>
using namespace std;
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
#define int long long
#define all(x) x.begin(), x.end()
#define endl '\n'
const int N=200005;
const int INF=1e18;
int n,m,ans=0;
vector<int> v(N),adj[N],t(N);
void dfs(int k,int pa,int deep,int cnt){
cnt+=t[k];
if(deep<m){
ans=max(ans,cnt);
}
for(int j:adj[k]){
if(j==pa)continue;
dfs(j,k,deep+1,cnt-v[j]-v[k]);
}
}
int32_t main() {
LCBorz;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>v[i];
t[i]=v[i];
}
for(int i=1;i<n;i++){
int a,b;cin>>a>>b;
adj[a].push_back(b);
adj[b].push_back(a);
t[a]+=v[b];
t[b]+=v[a];
}
for(int i=1;i<=n;i++){
dfs(i,i,0,-v[i]);
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8304 KB |
Output is correct |
2 |
Incorrect |
2 ms |
8284 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8304 KB |
Output is correct |
2 |
Incorrect |
2 ms |
8284 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4014 ms |
18004 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8304 KB |
Output is correct |
2 |
Incorrect |
2 ms |
8284 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |