# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
578961 |
2022-06-18T08:41:27 Z |
ddy888 |
Paprike (COI18_paprike) |
C++17 |
|
48 ms |
18136 KB |
#undef _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define fi first
#define si second
typedef pair<int,int> pi;
typedef tuple<int,int,int> ti;
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAXN = 100010;
int n, k;
vector<int> g[MAXN];
int ans;
int arr[MAXN];
int sum[MAXN];
priority_queue<pi> hit;
void dfs(int x, int p) {
sum[x] = arr[x];
for (auto i: g[x]) {
if (i == p) continue;
dfs(i, x);
sum[x] += sum[i];
hit.push({sum[i], i});
}
while (hit.size() && hit.top().fi + arr[x] > k) {
sum[x] -= hit.top().fi;
hit.pop();
++ans;
}
}
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; ++i) cin >> arr[i];
for (int i = 1; i < n; ++i) {
int u, v; cin >> u >> v;
g[u].pb(v);
g[v].pb(u);
}
dfs(1, 1);
cout << ans;
return 0;
}
# |
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 |
48 ms |
18136 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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |