Prázdny
Prázdny

Task 1 will be revealed 16.11.2026 at 18:00 CET

Login required

Claim a spot

At the race weekend near the city known for a distinctive architectural style, a monumental religious building and a city plan in which many blocks have their corners cut off, fans walk along the main fan zone near the paddock area. Along this zone there is a row of N stalls selling official team merchandise. The products sold at all stalls are essentially identical in quality, so the only important factors for a buyer are the price and the location of the stall.

Before opening your own stall, you study the behavior of fans in this area. You discover that most fans follow the same decision pattern:

  • a fan walks along the row of stalls,
  • compares prices at several stalls,
  • after visiting exactly K stalls, the fan stops and goes back to the stall with the lowest price seen so far,
  • if several stalls have the same lowest price, the fan chooses the one closest to the point where they stopped.

For example, suppose the stalls are arranged in a row and their prices are:

37, 34, 34, 35, 33

If a fan with K = 4 walks from left to right, they see prices 37, 34, 34, 35. At that point, they stop, return to the stall with the minimum observed price, and buy there. In this case, the third stall has the same price as the second, but it is closer to the stopping point. If the same fan enters from the other side, they would see 33, 35, 34, 34 and then stop and return to the fifth stall.

The number K of stalls a fan is willing to inspect before making a purchase depends on the fan’s patience, eagerness to bargain, and how much time remains before the next session. Different fans have different K. Research has shown that the average percentage of fans with a given value of K is (BK)
(1≤K≤N,0≤BK≤99, k=1NBK=100).
After the new stall is inserted, there are N + 1 stalls in total. However, the distribution of buyers remains the same: a buyer with parameter K still visits exactly K stalls, where 1 ≤ K ≤ N, before making a purchase.

Half of all fans move from the first stall to the N-th stall, and the other half move from the N-th stall to the first. Both groups follow the same buying behavior described above.

You are planning to open a new merchandising stall in the fan zone at the Spanish Grand Prix. Your goal is to choose:

  • the price at which you will sell the merchandise, and
  • the position of your stall in the row,

so as to maximize the expected average revenue.

A buyer contributes exactly P to the revenue if and only if they choose the new stall; otherwise they contribute 0. The expected average revenue is computed over all buyers, assuming that half of the buyers walk from left to right and half walk from right to left, and that BK percent of the buyers have parameter K.
 

 

Input (from file gp.in):

  • The first line contains the number of existing spots, (N).
  • The second line contains (N) integers: prices at each spot.
  • The third line contains (N) integers in the range 0 to 99: values (BK) for each (K).
    All numbers in each line are separated by spaces.

Constraints: (2≤N≤100), initial prices are integers from 1 to 9999.

Output (to file gp.out):
Print two integers: (L) and (P).

  • (L) ((0 < L < N)) is the number of existing spots after which the new one should be placed (you may not place your spot first or last).
  • (P) is the optimal price.

If there is more than one optimal solution, choose the one with the smallest (L), and among those, the one with the smallest (P).
Of course, brute force is not an option even if N is small enough

 

Example:

Input:

5

73 418 126 905 200

23 11 49 16 1

 

Expected output:

2 199

 

Your task:

Read input file and into the field with the answer, enter :

  • the resulting values
  • the country, which the story refers to
  • at the end paste the source code of your program.

Output:

You can download the correct result HERE.