#P8015. [COCI 2013/2014 #4] GUMA
[COCI 2013/2014 #4] GUMA
Problem Description
Given a rectangle with columns, the -th column must be evenly divided into parts by making horizontal cuts. Find the minimum number of cuts needed to finish the partition as required.
In one cut, you may cut in one or more columns that are not necessarily consecutive.
Input Format
The first line contains a positive integer , indicating that the rectangle has columns.
The next lines each contain a positive integer , indicating that the -th column must be evenly divided into parts by making horizontal cuts.
Output Format
One line containing a positive integer, indicating the minimum number of cuts.
1
2
5
5
2
3
7
14
15
9
4
2
4
1
2
2
2
8
4
2
7
Hint
[Sample Explanation #3]

A total of cuts.
[Constraints]
For of the testdata, .
For of the testdata, .
[Source]
The score of this problem is set according to the original COCI problem, with a full score of .
Translated from COCI2013-2014 CONTEST #4 T4 GUMA.
Translated by ChatGPT 5