409059: GYM103428 E CHASE!

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. CHASE!time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Setsuna likes staying at home. No matter what happens at school, she has little interest and only wants to go home to play games. One day when she was back, she opened a rhythm game and found that her favorite event was helding.

For each round in this event, a player has to play two different songs which are randomly chosen by system. There are totally $$$n$$$ songs in the system, and Setsuna is able to gain a score of $$$a_i$$$ if she plays the $$$i$$$-th song. The score of a round is the sum of scores of the two songs.

Initially the system presents two different songs which are randomly selected with equal probability. If the player is unsatisfied with the result, he can ask the system to reselect (of course randomly). But there are only $$$k$$$ opportunities of reselecting in total.

Setsuna had many questions. Firstly, she wanted to know her expected score under optimal decision. Secondly, she assumpted $$$Q$$$ cases, each of which was as the form of "the system selected the $$$x$$$-th song and the $$$y$$$-th song currently, and there were $$$c$$$ chances of reselecting left", and you need to answer whether she should accept the result, or decide to reselect, or both are OK if the difference of expected scores of these two choices under optimal decision is less or equal than $$$10^{-4}$$$.

Input

The first line containts three integers $$$n,k,Q$$$. ($$$2 \le n \le 10^5,\ 1 \le Q \le 10^5,\ 0 \le k \le 100$$$)

The second line contains $$$n$$$ integers $$$a_1,\cdots,a_n$$$. ($$$0 \le a_i \le 10^6$$$)

Next $$$Q$$$ lines each contains three integers $$$x,y,c$$$. ($$$1 \le x < y \le n,\ 0 \le c \le k$$$)

Output

The first line contains a real number, representing the maximum expected score. The absolute difference between your answer and the standard answer should be within $$$10^{-4}$$$.

For next $$$Q$$$ lines, if she should accept the result in the $$$i$$$-th case, output "accept"; if she should reselect, output "reselect"; if both are OK, output "both".

ExampleInput
3 2 1
30 40 50
1 2 1
Output
85.555555556
reselect

加入题单

算法标签: