Submission #1117585

#TimeUsernameProblemLanguageResultExecution timeMemory
1117585vjudge1Paprike (COI18_paprike)C++17
13 / 100
74 ms6800 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define itn int const int sz = 1e5 + 5; vector<int> g[sz]; signed main(){ int n,k; cin >> n >> k; vector<int> hmm(n+1); int a,b; for(int i=1;i<=n;++i)cin >> hmm[i]; for(int i=1;i<n;++i){ cin >> a >> b; g[a].push_back(b); g[b].push_back(a); } int cnt=0; int mink = 0; int cvb=0; for(int i=1;i<=n;++i){ cnt += hmm[i]; if(cnt > k){ mink++; cnt = hmm[i]; } } cnt = 0; for(int i=n;i>0;--i){ cnt += hmm[i]; if(cnt > k){ cvb++; cnt = hmm[i]; } } cout << min(cvb,mink); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...