8000 Update README.md · TopWork0ut/C-Cpp-algorithms@eaf6b14 · GitHub
[go: up one dir, main page]

Skip to content

Commit eaf6b14

Browse files
authored
Update README.md
1 parent 0259b8e commit eaf6b14

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
## Fourth Lab
1+
## The Fourth Lab
2+
23

34
## Electricians
45

@@ -8,22 +9,26 @@ You order the electric wire for connecting the poles from China, and it will tak
89

910
(In other words - you need to find such a sequence of pole heights that the wire connecting their tops will be the longest)
1011

12+
1113
## Input data:
1214

1315
The first line contains w - the distance between the pillars. The second line contains N numbers describing the maximum possible height for each pillar (i.e. an array of heights).
1416

17+
1518
## Output:
1619

1720
The maximum possible required length of the wire with 2 digits after the decimal point.
1821

22+
1923
## Constraints:
2024

2125
w, heights[i] - integers in the range 1 ... 100
2226
N < 50
2327

2428
Of course, you must ignore various physical constraints ala wire sagging or wire consumption per connection
2529

26-
### Examples:
30+
31+
## Examples:
2732
In:
2833
2
2934
3 3 3
@@ -52,6 +57,7 @@ In:
5257
Out:
5358
2738.18
5459

60+
5561
## Solution
5662

5763
The greatest height will be when the hypotenuse of the square triangle (the distance between the vertices of the pillars) is the greatest. This can be done if one of the adjacent pillars is set to height 1, and the other is left with the same height. But we need to consider two cases. The first is when height 1 is for even numbers of posts, 2 for odd numbers. Of course, when the array starts with 1, we will take only for odd numbers.

0 commit comments

Comments
 (0)
0