(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 #235001

#TimeUsernameProblemLanguageResultExecution timeMemory
235001DodgeBallManPaprike (COI18_paprike)C++14
100 / 100
91 ms17656 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, k, h[N], ans; vector<int> g[N]; int dfs( int u, int p ) { vector<int> v; for( int vv : g[u] ) if( vv != p ) v.emplace_back( dfs( vv, u ) ); sort( v.begin(), v.end() ); int sum = h[u]; for( int i : v ) { if( sum + i > k ) ans++; else sum += i; } return sum; } int main() { scanf("%d %d",&n,&k); for( int i = 1 ; i <= n ; i++ ) scanf("%d",&h[i]); for( int i = 1, a, b ; i < n ; i++ ) { scanf("%d %d",&a,&b); g[a].emplace_back( b ), g[b].emplace_back( a ); } dfs( 1, 0 ); printf("%d",ans); return 0; }

Compilation message (stderr)

paprike.cpp: In function 'int main()':
paprike.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&k);
     ~~~~~^~~~~~~~~~~~~~~
paprike.cpp:24:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for( int i = 1 ; i <= n ; i++ ) scanf("%d",&h[i]);
                                     ~~~~~^~~~~~~~~~~~
paprike.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&a,&b);
         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...