1070D - Garbage Disposal - CodeForces Solution


greedy *1300

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
using namespace std;
long long n,k,x,yu,z,cnt;
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(yu>0) x=x-k+yu,cnt++;
        z=x/k;cnt+=z;
        yu=x%k;
    }
    if(yu>0)cnt++;
    cout<<cnt;
}

   	 	    	     	  		   	  	 	


Comments

Submit
0 Comments
More Questions

1366C - Palindromic Paths
336A - Vasily the Bear and Triangle
926A - 2-3-numbers
276D - Little Girl and Maximum XOR
1253C - Sweets Eating
1047A - Little C Loves 3 I
758D - Ability To Convert
733A - Grasshopper And the String
216A - Tiling with Hexagons
1351B - Square
1225A - Forgetting Things
1717A - Madoka and Strange Thoughts
1717B - Madoka and Underground Competitions
61B - Hard Work
959B - Mahmoud and Ehab and the message
802G - Fake News (easy)
1717C - Madoka and Formal Statement
420A - Start Up
1031A - Golden Plate
1559C - Mocha and Hiking
427B - Prison Transfer
330A - Cakeminator
426A - Sereja and Mugs
363A - Soroban
1585C - Minimize Distance
1506E - Restoring the Permutation
1539A - Contest Start
363D - Renting Bikes
1198D - Rectangle Painting 1
1023B - Pair of Toys