# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44032 | 2018-03-29T11:56:43 Z | Lkvatashidze | Paprike (COI18_paprike) | C++17 | 58 ms | 13156 KB |
#include <bits/stdc++.h> using namespace std; void DFS(int,int); int a[100005], dp[100005]; int n, Q; vector < vector < int > > g; int cnt; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> Q; g.resize(n+1); for (int k=1; k<=n; k++) cin >> a[k]; for (int k=1; k<n; k++) { int x, y; cin >> x >> y; g[x].push_back(y); g[y].push_back(x); } DFS(1,-1); cout << cnt; return 0; } void DFS (int v, int p) { dp[v]=a[v]; for (int k=0; k<g[v].size(); k++) { int to=g[v][k]; if (to==p) continue; DFS(to,v); if (dp[v]+dp[to]>Q) { cnt++; } else { dp[v]+=dp[to]; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 456 KB | Output is correct |
3 | Correct | 2 ms | 540 KB | Output is correct |
4 | Incorrect | 2 ms | 540 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 56 ms | 13084 KB | Output is correct |
2 | Correct | 56 ms | 13108 KB | Output is correct |
3 | Correct | 57 ms | 13124 KB | Output is correct |
4 | Correct | 56 ms | 13124 KB | Output is correct |
5 | Correct | 54 ms | 13124 KB | Output is correct |
6 | Correct | 58 ms | 13156 KB | Output is correct |
7 | Correct | 54 ms | 13156 KB | Output is correct |
8 | Correct | 50 ms | 13156 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 456 KB | Output is correct |
3 | Correct | 2 ms | 540 KB | Output is correct |
4 | Incorrect | 2 ms | 540 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 456 KB | Output is correct |
3 | Correct | 2 ms | 540 KB | Output is correct |
4 | Incorrect | 2 ms | 540 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |