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

#TimeUsernameProblemLanguageResultExecution timeMemory
105512faustaadpPaprike (COI18_paprike)C++17
100 / 100
143 ms17484 KiB
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define fi first #define se second typedef long long ll; using namespace std; ll n,k,i,a[101010],ta,tb,has,bes[101010]; vector<ll> v[101010]; void dfs(ll aa,ll bb) { bes[aa]=a[aa]; vector<ll> tem; ll ii; for(ii=0;ii<v[aa].size();ii++) { if(v[aa][ii]==bb)continue; dfs(v[aa][ii],aa); tem.pb(bes[v[aa][ii]]); } sort(tem.begin(),tem.end()); for(ii=0;ii<tem.size();ii++) if(bes[aa]+tem[ii]<=k) bes[aa]+=tem[ii]; else has++; } int main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); cin>>n>>k; for(i=1;i<=n;i++)cin>>a[i]; for(i=1;i<n;i++) { cin>>ta>>tb; v[ta].pb(tb); v[tb].pb(ta); } dfs(1,1); cout<<has<<"\n"; }

Compilation message (stderr)

paprike.cpp: In function 'void dfs(ll, ll)':
paprike.cpp:15:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ii=0;ii<v[aa].size();ii++)
           ~~^~~~~~~~~~~~~
paprike.cpp:22:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ii=0;ii<tem.size();ii++)
           ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...