Cut the sticks
Cut the sticks You are given sticks, where the length of each stick is a positive integer. A cut operation is performed on the sticks such that all of them are reduced by the length of the smallest stick. ---Solution--- #include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int compare (const void * a, const void * b) { return ( *(int*)a - *(int*)b ); } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int element,k; cin>>element; int array[element]; for(int i=0;i<element;i++) { cin>>array[i]; } qsort (array, element, sizeof(int), compare); int p=element; for(int i=0;i<element;i++) { if(array[i]!=0) {cout<<p<<endl; if(p<=1) {break;} for(int j=element-1;j>=i;j--)