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>
using namespace std;
#define Study ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ff first
#define ss second
#define ins insert
#define all(x) x.begin(),x.end()
#define fori(x,y,z) for(ll x=y;x<=z;x++)
const ll INF=1e9;
const ll sz=1e5+10;
const ll mod=1e9+7;
void work(){
ll n,k;
cin>>n>>k;
vector<ll>pref(n+10,0);
vector<ll>a(n+10);
ll cuts=0,csum=0;
fori(i,1,n)
cin>>a[i];
vector<pair<ll,ll>>pairs(n+10);
fori(i,1,n-1)
cin>>pairs[i].ff>>pairs[i].ss;
for(ll i=n;i>=1;i--){
csum+=a[i];
if(csum>k){
csum=a[i];
cuts++;
}
}
cout<<cuts;
}
int main(){
Study;
ll t=1;
//cin>>t;
while(t--){
work();
}
}
# | 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... |