# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
982733 |
2024-05-14T16:48:38 Z |
vjudge1 |
Chase (CEOI17_chase) |
C++17 |
|
4000 ms |
7248 KB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, v, res = 0, x, y;
bool flag;
vector<int> a;
vector<vector<int>> graph;
void dfs(int i, int j, int p, int sum, int sus, int len) {
if(len > v) return;
sum += a[i];
//sus += a[i];
for(int k : graph[i]) {
if(k != p) sum += a[k];
}
//if(flag) cout << i << " " << j << " " << p << " " << sum << " " << sus << " " << len << "\n";
if(i == j) {
//if(flag) cout << sum - sus << "\n";
res = max(res, sum - sus);
return;
}
for(int k : graph[i]) {
if(k != p) dfs(k, j, i, sum - a[k], sus, len + 1);
}
}
signed main() {
cin >> n >> v;
a = vector<int>(n), graph = vector<vector<int>>(n);
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < n - 1; i++) {
cin >> x >> y;
x--, y--;
graph[x].push_back(y);
graph[y].push_back(x);
}
//
for(int i = 0; i < n; i++) {
for(int j = i + 1; j < n; j++) {
dfs(i, j, -1, 0, a[i], 1);
}
}
//
cout << res << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4014 ms |
7248 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |