# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
982725 |
2024-05-14T16:42:17 Z |
vjudge1 |
Chase (CEOI17_chase) |
C++17 |
|
4000 ms |
13140 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) {
sum += a[i];
sus += a[i];
for(int k : graph[i]) {
if(k != p) sum += a[k];
}
if(i == j) {
res = max(res, sum - sus);
return;
}
for(int k : graph[i]) {
if(k != p) dfs(k, j, i, sum - a[k], sus);
}
}
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++) {
//if len > v stop
dfs(i, j, -1, 0, 0);
}
}
//
cout << res << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4098 ms |
13140 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |