이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |