(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #678152

#TimeUsernameProblemLanguageResultExecution timeMemory
678152Tien_NoobPaprike (COI18_paprike)C++17
100 / 100
70 ms19052 KiB
//Make CSP great again //Vengeance #include <bits/stdc++.h> #define TASK "TESTCODE" #define Log2(x) 31 - __builtin_clz(x) using namespace std; const int N = 1e5; vector<int> adj[N + 1]; int res, a[N + 1], n, h; void read() { cin >> n >> h; for (int i = 1; i <= n; ++ i) { cin >> a[i]; } for (int i = 1; i < n; ++ i) { int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } } int DFS(int u, int p) { vector<int> f; for (int v : adj[u]) { if (v == p) { continue ; } f.push_back(DFS(v, u)); } sort(f.begin(), f.end()); int x = a[u]; for (int i : f) { if (x + i <= h) { x += i; } else { ++res; } } return x; } void solve() { DFS(1, 0); cout << res; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); if (fopen(TASK".INP", "r")) { freopen(TASK".INP", "r", stdin); //freopen(TASK".OUT", "w", stdout); } int t = 1; bool typetest = false; if (typetest) { cin >> t; } for (int __ = 1; __ <= t; ++ __) { //cout << "Case " << __ << ": "; read(); solve(); } }

Compilation message (stderr)

paprike.cpp: In function 'int main()':
paprike.cpp:62:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen(TASK".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...