제출 #1117604

#제출 시각아이디문제언어결과실행 시간메모리
1117604vjudge1Paprike (COI18_paprike)C++17
13 / 100
27 ms18020 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 = 1e8 , MOD = 998244353; ll a[sz]; vector<ll> g[sz]; ll i , j , k; void solve(){ ll n , m , sum = 0 , ans = 0; 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); } for(i = 1 ; i <= n ; i++){ if(sum + a[i] > m){ ans++; sum = 0; } sum += a[i]; } cout << ans << endl; } signed main(){ speedyboy; ll t = 1; //cin >> t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...