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
#define pb push_back
#define in insert
#define F first
#define S second
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define endl '\n'
#define pii pair<ll,ll>
using namespace std;
const ll INF =1e18, mod = 1e9 + 7, N = 1e5 + 5;
ll gcd(ll a, ll b){
if(b == 0){
return a;
}
return gcd(b, a % b);
}
ll lcm(ll a, ll b){
return (a / gcd(a,b)) * b;
}
void solve(){
ll n,k;
cin >> n >> k;
ll a[n + 1];
for(int i = 1; i <= n; i++){
cin >> a[i];
}
ll x,y;
ll cnt1 = 0;
ll cnt2 = 0;
ll summ = 0;
for(int i = 0; i < n - 1; i++){
cin >> x >> y;
}
for(int i = 1; i <= n; i++){
if(summ + a[i] <= k){
summ += a[i];
}
else{
cnt1++;
summ = a[i];
}
}
// cout << cnt1 << " " << cnt2 << endl;
cout << cnt1 << endl;
}
int main(){
fast;
ll t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}
Compilation message (stderr)
paprike.cpp: In function 'void solve()':
paprike.cpp:32:8: warning: unused variable 'cnt2' [-Wunused-variable]
32 | ll cnt2 = 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... |