# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29295 | 2017-07-19T01:41:05 Z | 김동현(#1164) | Dynamite (POI11_dyn) | C++14 | 1976 ms | 30400 KB |
#include <bits/stdc++.h> using namespace std; int n, m, d[300010], ans; vector<int> e[300010]; int f(int x, int p, int c){ int t = 0, v = 0; for(auto &i : e[x]){ if(i != p){ int u = f(i, x, c); if(!u) continue; if(u > 0) v = max(v, u); else t = min(t, u); } } if(abs(t) >= c){ ans++; return c; } if(!v && !t) return -d[x]; if(v > abs(t)) return v - 1; return t - 1; } int can(int k){ ans = 0; if(f(1, 0, k) < 0) ans++; return ans <= m; } int main(){ scanf("%d%d", &n, &m); for(int i = 1; i <= n; i++) scanf("%d", d + i); for(int i = 0, x, y; i < n - 1; i++){ scanf("%d%d", &x, &y); e[x].push_back(y); e[y].push_back(x); } if(count(d + 1, d + n + 1, 1) <= m){ puts("0"); return 0; } int st = 1, en = n - 1; while(st <= en){ int mi = (st + en) / 2; if(can(mi)) en = mi - 1; else st = mi + 1; } printf("%d\n", st); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 10224 KB | Output is correct |
2 | Correct | 0 ms | 10224 KB | Output is correct |
3 | Correct | 3 ms | 10224 KB | Output is correct |
4 | Correct | 0 ms | 10224 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 10224 KB | Output is correct |
2 | Correct | 3 ms | 10224 KB | Output is correct |
3 | Correct | 0 ms | 10224 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 10224 KB | Output is correct |
2 | Correct | 3 ms | 10224 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 10224 KB | Output is correct |
2 | Correct | 3 ms | 10224 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 10620 KB | Output is correct |
2 | Correct | 39 ms | 11016 KB | Output is correct |
3 | Correct | 39 ms | 11148 KB | Output is correct |
4 | Correct | 63 ms | 12760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 63 ms | 12072 KB | Output is correct |
2 | Correct | 159 ms | 12600 KB | Output is correct |
3 | Correct | 309 ms | 12732 KB | Output is correct |
4 | Correct | 246 ms | 15620 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 166 ms | 13656 KB | Output is correct |
2 | Correct | 129 ms | 13660 KB | Output is correct |
3 | Correct | 459 ms | 13392 KB | Output is correct |
4 | Correct | 199 ms | 18300 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 843 ms | 16692 KB | Output is correct |
2 | Correct | 376 ms | 18156 KB | Output is correct |
3 | Correct | 866 ms | 25328 KB | Output is correct |
4 | Correct | 1579 ms | 25324 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1883 ms | 22112 KB | Output is correct |
2 | Correct | 1186 ms | 20536 KB | Output is correct |
3 | Correct | 1976 ms | 24972 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1649 ms | 28388 KB | Output is correct |
2 | Correct | 1279 ms | 20540 KB | Output is correct |
3 | Correct | 1866 ms | 30400 KB | Output is correct |
4 | Correct | 559 ms | 21680 KB | Output is correct |