#1270
Unrated
Kvalitetni
시간 제한
1s
메모리 제한
64MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

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 Z1Z_{1} is of good quality. Such expression is of the following form: (x) ● For example, if Z1Z_{1} = 5, then (4) is a quality expression. ● If A1A_{1}, A2A_{2}, …, AkA_{k} are quality expressions such that 2 ≤ k ≤ K and the sum of these expressions is at most ZkZ_{k}, then the following expressions are of good quality: (A1A_{1} +A2A_{2} +...+AkA_{k}) (A1A_{1} *A2A_{2} ...AkA_{k}) 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 Z1Z_{1}, …, ZKZ_{K}, separated by space (1 ≤ Z1Z_{1}, …, ZKZ_{K} ≤ 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 10310^{-3}.

예제 입력 1

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

예제 출력 1

6.00000

예제 입력 2

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

예제 출력 2

6.00000

예제 입력 3

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

예제 출력 3

8.000000000
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.