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