Jimmy's birthday is a puzzle cube. Jimmy put the
n tower, second tower
i elevation is
ai (1 ≤
ai ≤ 10
9, 1 ≤
n ≤ 10
5,
i = 1 ÷
n .
Jimmy is in love with the integer
k , so the tower blocks repeatedly called harmonic if it has an average elevation of
k (1 ≤
k ≤ 10
9).
Requirements: Have
n,
k and
ai (
i = 1 ÷
k) . Please identify the longest sequence harmonic tower, find the first tower and find the length of the sequence. If more rows exist along the length of the sequence, only the first tower is located at a minimum. If that does not exist, the tower offers a range of
0.
Data: In from the text file
CUBICS.INP:
• The first line contains two integers
n and
k.
• The second line contains
n integers
a1,
a2, ...,
an.
Results: Provide
CUBICS.OUT text file on a second line of the same: find the length of the sequence and number of the first tower or a
0 if the row does not exist.
INP
5 3
1 2 3 4 6
OUT
3 2
Who does the data structure with suggestions to help e!
It has been suggested but i don't understand
pair <int,int> a [n +1]
1 2 3 4 5 6
|
for (i = 0; i <= n; + + i)
{
fi>> a [i]. first;
fi>> a [i]. second = i;
}
a [i]. first-= k;
|
:(:(