Logo
(追記) (追記ここまで)

13942번 - Kvalitetni 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 64 MB1810956.250%

문제

A quality arithmetic expression consists of brackets, number and operations of multiplication and addition.

A quality arithmetic expression is defined recursively in the following way:

  • An expression consisting of only one positive real​ number smaller than or equal to Z1 is of good quality.
    Such expression is of the following form:
    (x)
    For example, if Z1 = 5, then (4) is a quality expression.
  • If A1 , A2 , …, Ak are quality expressions such that 2 k K and ≤ ≤ the sum​ of these expressions is at most Zk , then the following expressions are of good quality:
    (A1+A2+...+Ak )
    (A1 *A2 *...*Ak )

You are given a quality expression where the numbers are replaced by question marks. Determine the maximal​ possible value that the expression could have had.

입력

The first line of input contains integer K (2 ≤ K ≤ 50).

The second line of input contains integers Z1 , …, ZK, separated by space (1 ≤ Z1 , …, ZK ≤ 50).

The third line of input contains one quality arithmetic expression in the described format. Arithmetic expression consists of: ‘?’, ‘*’, ‘+’, ‘(‘, ‘)’, and its length is 1 000 000 characters, at most.

출력

You must output the maximal possible value of the expression.

A solution is considered correct if the absolute or relative deviation from the official solution is less than 10-3 .

제한

예제 입력 1

2
10 6
((?)+(?))

예제 출력 1

6.00000

예제 입력 2

3
2 5 3
(((?)+(?))*(?))

예제 출력 2

6.00000

예제 입력 3

3
2 10 6
((?)*(?)*(?))

예제 출력 3

8.000000000

힌트

The expression ((3)+(3)) satisfies the conditions, so it is a quality expression, and it is easy to check that 6 is the maximal value.

출처

Contest > Croatian Open Competition in Informatics > COCI 2016/2017 > Contest #3 4번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /