This page is still under construction.

Parts of this page are still being built. What you see may change.

Bargain or No Bargain

Time limit1sMemory limit128 MB

Summary
Given prize values and a budget M, decide whether optimal play maximizing expected log utility yields expected prize money above M.
Level

Medium7 of 10

Topics
Dynamic programming, Probability, Math, Recursion
Solved
No attempts yet

Problem

The NZPC Entertainment Division has planned a new TV game show called "Bargain or No Bargain". In the show there are several briefcases, each containing a cheque for a fixed amount of prize money. The list of prize values (one per briefcase) is announced in advance, but nobody knows which briefcase holds which prize. A single contestant is handed one briefcase without learning its contents.

The game is played in a series of rounds. In every round (including the first), the NZPC Bank first makes the contestant a cash offer, which the contestant may accept in order to quit the game immediately, forfeiting the contents of their own briefcase. If the contestant declines, they then open one of the remaining closed briefcases, revealing its prize and thereby eliminating the possibility that this prize is in their own briefcase. Play continues until either the contestant accepts an offer, or every briefcase except the contestant's has been opened. In the latter case the contestant's briefcase is opened and they leave with the cheque it contains.

Game details:

  • Let SS be the sum of the remaining prizes and NN the number of remaining prizes. The bank offer is always S/N2S / N^2.
  • Each briefcase is equally likely to contain each of the remaining prizes.
  • The contestant plays optimally to maximize the expected value of u(x)u(x), where u(x)=ln⁡(x)u(x) = \ln(x) is the utility of winning xx dollars (the natural logarithm). This concave utility models the fact that a fixed increase in wealth is worth less when you already have more money.

Given a set of prize values, decide whether a contestant playing optimally would, on average, win more than a given amount MM of prize money. The optimal strategy maximizes the expected utility; the quantity compared against MM is the resulting expected prize money in dollars.

Input

The input consists of several game scenarios. Each scenario is given on two lines. The first line lists the dollar values of the prizes, separated by single spaces; every prize value is a positive integer. The second line contains a single positive integer MM, the largest expected prize money per game (under optimal play, as defined above) that the NZPC can afford. Each scenario has at most 25 prizes, and prize values may repeat.

Output

For each game scenario, if the expected prize money per game under optimal play is greater than MM, print UNACCEPTABLE on a line by itself; otherwise print OK on a line by itself. The input is terminated by a line containing only -1, which must not be processed.

Examples2

  1. Example 1

    Input
    1 10 100 1000
    200
    1 3000 50 750 10000
    1500
    -1
    
    Expected output
    OK
    UNACCEPTABLE
    
  2. Example 2

    Input
    100
    50
    100
    200
    -1
    
    Expected output
    UNACCEPTABLE
    OK