This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
using namespace std;
int main(){
fast;
ll n,m,s=0,cem=0;
cin>>n>>m;
ll a[n];
for(ll i=0;i<n;i++){
cin>>a[i];
}
for(ll j=0;j<n-1;j++){
ll u,v;
cin>>u>>v;
}
for(ll i=0;i<n;i++){
if(cem+a[i]>m){
s++;
cem=a[i];
}
else{
cem+=a[i];
}
}
cout<<s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |