Ropes left after every removal of smallest | C ++ program to print how many Ropes are Left After Every Cut ; Function print how many Ropes are Left AfterEvery Cutting operation ; sort all Ropes in increase of there length ; min length rope ; now traverse through the given Ropes in increase order of length ; After cutting if current rope length is greater than '0' that mean all ropes to it 's right side are also  greater than 0 ; now current rope become min length rope ; After first operation all ropes length become zero ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void cuttringRopes ( int Ropes [ ] , int n ) { sort ( Ropes , Ropes + n ) ; int singleOperation = 0 ; int cuttingLenght = Ropes [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( Ropes [ i ] - cuttingLenght > 0 ) { cout << ( n - i ) << " ▁ " ; cuttingLenght = Ropes [ i ] ; singleOperation ++ ; } } if ( singleOperation == 0 ) cout << "0 ▁ " ; } int main ( ) { int Ropes [ ] = { 5 , 1 , 1 , 2 , 3 , 5 } ; int n = sizeof ( Ropes ) / sizeof ( Ropes [ 0 ] ) ; cuttringRopes ( Ropes , n ) ; return 0 ; }