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

#TimeUsernameProblemLanguageResultExecution timeMemory
469950Blobo2_Blobo2Paprike (COI18_paprike)C++14
100 / 100
73 ms17988 KiB
/* Editor: Abdelrahman Hossam Nickname: Blobo2_Blobo2 IOI next year isA :) */ /*#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-funroll-loops") #pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")*/ #include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" #define all(v) v.begin(),v.end() #define gen(arr,n,nxt) generate(arr,arr+n,nxt) #define Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty ios_base::sync_with_stdio(false);cin.tie(0); #define EPS 0.00000001 const int mo=1e9+7,INF=1e18; int nxt(){int x;cin>>x;return x;} int n,k; vector<int>adj[100001]; int val[100001]; int cnt=0; void dfs(int u =0,int par =-1){ if(adj[u].size() == 0) return; for(auto v:adj[u]) if(v!=par) dfs(v,u); vector<int>v2; for(auto v:adj[u]) if(v!=par) v2.push_back(val[v]); sort(all(v2)); for(int i=0;i<v2.size();i++){ if(val[u]+v2[i] <= k) val[u] += v2[i]; else cnt++; } return; } signed main(){ Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty n=nxt(),k=nxt(); gen(val,n,nxt); for(int i=0;i<n-1;i++){ int x= nxt()-1,y=nxt()-1; adj[x].push_back(y); adj[y].push_back(x); } dfs(); cout<<cnt; return 0; }

Compilation message (stderr)

paprike.cpp: In function 'void dfs(long long int, long long int)':
paprike.cpp:38:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i=0;i<v2.size();i++){
      |                 ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...