-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathcut_stick.cpp
More file actions
50 lines (49 loc) · 882 Bytes
/
cut_stick.cpp
File metadata and controls
50 lines (49 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n;
int i,j,k;
cin >> n;
vector<int> arr(n);
for(int arr_i = 0;arr_i < n;arr_i++){
cin >> arr[arr_i];
}
while(1)
{
int min=arr[0];
int rem=0;
for(i=0;i<n;i++)
{
if(arr[i]!=0)
{
rem++;
}
}
if(rem==0)
break;
cout<<rem<<"\n";
for(i=1;i<n;i++)
{
if(arr[i]<min && arr[i]!=0)
{
min=arr[i];
}
if(min==0)
{
min=arr[i];
}
}
for(i=0;i<n;i++)
{
if(arr[i]!=0)
{
arr[i]-=min;
}
}
}
return 0;
}