# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
603350 | 2022-07-24T04:04:56 Z | Zanite | Paprike (COI18_paprike) | C++17 | 52 ms | 21832 KB |
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; using ll = long long; using pll = pair<ll, ll>; #define fi first #define se second const int maxN = 1e5 + 5; int n; ll k, h[maxN], sum[maxN]; vector<int> adj[maxN]; int dfs(int cur, int par) { int ret = 0; sum[cur] = h[cur]; vector<int> spice; for (auto &nxt : adj[cur]) { if (nxt == par) continue; ret += dfs(nxt, cur); spice.push_back(sum[nxt]); } sort(spice.begin(), spice.end()); for (int i = 0; i < spice.size(); i++) { if (sum[cur] + spice[i] >= k) ret++; else sum[cur] += spice[i]; } return ret; } int main() { scanf("%d %lld", &n, &k); for (int i = 1; i <= n; i++) { scanf("%lld", &h[i]); } for (int u, v, i = 1; i < n; i++) { scanf("%d %d", &u, &v); adj[u].push_back(v); adj[v].push_back(u); } printf("%d\n", dfs(1, 0)); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 21724 KB | Output is correct |
2 | Correct | 50 ms | 21832 KB | Output is correct |
3 | Correct | 49 ms | 21800 KB | Output is correct |
4 | Correct | 48 ms | 21828 KB | Output is correct |
5 | Correct | 51 ms | 21724 KB | Output is correct |
6 | Correct | 52 ms | 21772 KB | Output is correct |
7 | Correct | 49 ms | 21712 KB | Output is correct |
8 | Incorrect | 46 ms | 21368 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |