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

#TimeUsernameProblemLanguageResultExecution timeMemory
1117767vjudge1Paprike (COI18_paprike)C++17
100 / 100
42 ms30608 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define endl '\n' #define pb push_back #define speedyboy ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define all(x) x.begin() , x.end() #define F first #define S second #define pll pair<ll , ll> #define pss pair<string , string> #define YES cout << "YES" << endl; #define NO cout << "NO" << endl; const ll sz = 5e5 + 5 , INF = 1e18 , MOD = 998244353; ll a[sz]; vector<ll> g[sz]; ll ans; void dfs(ll n , ll u , ll m , ll &cursum){ cursum = a[n]; vector<ll> v; for(ll i : g[n]){ if(i != u){ ll changesum = 0; dfs(i , n , m , changesum); v.pb(changesum); } } sort(all(v)); for(ll i = 0 ; i < v.size() ; i++){ if(cursum + v[i] > m){ ans++; } else{ cursum += v[i]; } } if(cursum > m){ ans++; } } ll i , j , k; void solve(){ ll n , m; cin >> n >> m; for(i = 1 ; i <= n ; i++){ cin >> a[i]; } for(i = 1 ; i < n ; i++){ ll u , v; cin >> u >> v; g[u].pb(v); g[v].pb(u); } ll cursum = 0; dfs(1 , -1 , m , cursum); cout << ans << endl; } signed main(){ speedyboy; ll t = 1; //cin >> t; while(t--){ solve(); } }

Compilation message (stderr)

paprike.cpp: In function 'void dfs(long long int, long long int, long long int, long long int&)':
paprike.cpp:35:22: 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]
   35 |     for(ll i = 0 ; i < v.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...