-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path4883.cpp
More file actions
59 lines (49 loc) · 724 Bytes
/
4883.cpp
File metadata and controls
59 lines (49 loc) · 724 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
51
52
53
54
55
56
57
58
59
#include <iostream>
using namespace std;
int numPitches;
int pitch[200];
int maxPitch;
int total;
int climbers;
int calc(int ropeLength);
int main()
{
while(cin >> numPitches)
{
if(numPitches)
{
for(int i = 0; i < numPitches; i++)
{
cin >> pitch[i];
}
cout << calc(50) << " " << calc(60) << " " << calc(70) << endl;
}
else
{
break;
}
}
return 0;
}
int calc(int ropeLength)
{
maxPitch = pitch[0];
total = pitch[0];
for(int i = 1; i < numPitches; i++)
{
total += pitch[i];
if(pitch[i] > maxPitch)
{
maxPitch = pitch[i];
}
}
climbers = (ropeLength / maxPitch) + 1;
if((ropeLength < (2 * total)) || (climbers < 2))
{
return 0;
}
else
{
return climbers;
}
}