# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
44043 | 2018-03-29T12:45:39 Z | Lkvatashidze | Paprike (COI18_paprike) | C++11 | 87 ms | 34688 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]; set < int > st; for (int k=0; k<g[v].size(); k++) { int to=g[v][k]; if (to==p) continue; DFS(to,v); st.insert(dp[to]); } while (!st.empty()) { int q=(*st.begin()); if (dp[v]+q<Q) { dp[v]+=q; } else { cnt++; } st.erase(st.begin()); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 320 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 87 ms | 21224 KB | Output is correct |
2 | Correct | 67 ms | 23232 KB | Output is correct |
3 | Correct | 64 ms | 25400 KB | Output is correct |
4 | Correct | 69 ms | 27476 KB | Output is correct |
5 | Correct | 64 ms | 29408 KB | Output is correct |
6 | Correct | 62 ms | 31220 KB | Output is correct |
7 | Correct | 62 ms | 33144 KB | Output is correct |
8 | Incorrect | 68 ms | 34688 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 320 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 320 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |