Datasets:

Modalities:
Image
Text
Formats:
parquet
Size:
< 1K
Tags:
code
Libraries:
Datasets
pandas
License:
hackercup / 2013 /round2 /cake_cutting.html
wjomlex's picture
2013 Problems
c623d8c verified
raw
history blame
1.33 kB
<p>"Happy birthday to you... Happy birthday to you... Happy birthday to Grovyle... Happy birthday to you..."</p>
<p>Today is Grovyle's birthday and he is going to invite his friends to his birthday party.
To have an awesome party, each of the attendants should get one piece of cake.
Your job is to help Grovyle invite as many friends as you can.
</p>
<p>
However, Grovyle's parents are very mean, and make him use the following rules when cutting his cake:
<li>There is only ONE cylindrical cake.
<li>Grovyle cuts the cake <b>N</b> times, each cut being perpendicular to the surface of the cake.
<li>The <b>i</b>-th cut is a broken line with <b>a</b>[<b>i</b>] vertices.
<li>The knife is only allowed to intersect the edge of the cylindrical cake at the start and end of the cut.
</p>
<p>
What is the maximum number of pieces Grovyle could get?
</p>
<h3>Input</h3>
<p>
The first line contains an integer <b>T</b>, <b>T</b> &le; 50, indicating the number of test cases.
Each test case begins with an integer <b>N</b>, 1 &le; <b>N</b> &le; 100, followed by <b>N</b> integers <b>a</b>[<b>i</b>], 0 &le; <b>a</b>[<b>i</b>] &lt; 400, which indicate the number of vertices in the <b>i</b>-th cut.
</p>
<h3>Output</h3>
<p>
For each test case, output "Case #i: " followed by the maximum number of pieces of cake Grovyle can cut.
</p>