# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
307302 |
2020-09-27T15:24:12 Z |
zoember |
Traffic (IOI10_traffic) |
C++11 |
|
53 ms |
48248 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN = 1e6, MAXN2 = 2e9;
int total = 0, ans = MAXN2;
vector<int> adj[MAXN];
int dfs(int vertex, int parent, int p[]) {
int cnt = 0, maxcon = 0;
for(int next: adj[vertex]) {
if(next != parent) {
int curr = dfs(next, vertex, p);
maxcon = max(maxcon, curr);
cnt += curr;
}
}
maxcon = max(maxcon, total-p[vertex]-maxcon);
ans = min(ans, maxcon);
cnt += p[vertex];
return cnt;
}
int LocateCentre(int n, int p[], int s[], int d[]) {
for(int i=0; i<(n-1); i++) {
adj[s[i]].push_back(d[i]);
adj[d[i]].push_back(s[i]);
}
for(int i=0; i<n; i++) {
total += p[i];
}
dfs(0, -1, p);
cout << ans << endl;
}
//int main() {
//// freopen("hayfeast.in", "r", stdin);
//// freopen("hayfeast.out", "w", stdout);
// ios_base::sync_with_stdio(false);
// cin.tie(NULL); cout.tie(NULL);
// int n;
// cin >> n;
// int p[n] = {0}, s[n] = {0}, d[n] = {0};
// for(int i=0; i<n; i++) {
// cin >> p[i];
// }
// for(int i=0; i<(n-1); i++) {
// cin >> s[i];
// }
// for(int i=0; i<(n-1); i++) {
// cin >> d[i];
// }
// LocateCentre(n, p, s, d);
//}
Compilation message
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:34:1: warning: no return statement in function returning non-void [-Wreturn-type]
34 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
53 ms |
48248 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
53 ms |
48248 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
53 ms |
48248 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
53 ms |
48248 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |