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 <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int llo ;
#define mp make_pair
#define pb push_back
#define a first
#define b second
vector<llo> adj[100001];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
llo n,k;
cin>>n>>k;
llo it[n];
for(llo i=0;i<n;i++){
cin>>it[i];
}
llo aa,bb;
for(llo i=0;i<n-1;i++){
cin>>aa>>bb;
adj[aa-1].pb(bb-1);
adj[bb-1].pb(aa-1);
}
llo tot=0;
llo ind=0;
llo co=0;
while(ind<n){
tot=0;
while(ind<n){
if(tot+it[ind]<=k){
ind+=1;
tot+=it[ind-1];
}
else{
break;
}
}
//cout<<tot<<endl;
co+=1;
}
cout<<co-1<<endl;
return 0;
}
# | 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... |