QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#480138#4687. Weather ReportGeothermalAC ✓118ms11180kbPython31.3kb2024-07-16 08:41:552024-07-16 08:41:57

Judging History

你现在查看的是最新测评结果

  • [2024-07-16 08:41:57]
  • 评测
  • 测评结果:AC
  • 用时:118ms
  • 内存:11180kb
  • [2024-07-16 08:41:55]
  • 提交

answer

import heapq
N = int(input())
S = input()
A = [int(round(float(s)*1000000)+0.5) for s in S.split(' ')]



choose = []
for i in range(21):
    choose.append([])
    for j in range(21):
        if (i < j): 
            choose[i].append(0)
        elif (j == 0):
            choose[i].append(1)
        else:
            choose[i].append(choose[i-1][j-1] + choose[i-1][j])


ans = 0
q = []
for a in range(N+1):
    for b in range(N+1):
        for c in range(N+1):
            if (a+b+c <= N):
                cur = [a, b, c, N-a-b-c]
                ways = 1
                for i in range(4):
                    for j in range(cur[i]):
                        ways *= A[i]
                for i in range(N):
                    ways = ways / 1000000
                val = choose[N][a] * choose[N-a][b] * choose[N-a-b][c]
                heapq.heappush(q, [ways, val])

while len(q) > 1 or q[0][1] > 1:
    cur = heapq.heappop(q)
    if cur[1] == 1:
        nxt = heapq.heappop(q)
        heapq.heappush(q, [cur[0]+nxt[0], 1])
        ans += cur[0]+nxt[0]
        if (nxt[1] > 1):
            heapq.heappush(q, [nxt[0], nxt[1]-1])
    else:
       cnt = cur[1] // 2
       ans += cnt * 2 * cur[0]
       heapq.heappush(q, [cur[0]*2, cnt])
       if (cur[1] % 2 == 1):
           heapq.heappush(q, [cur[0], 1])

print(ans)






Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 16ms
memory: 10784kb

input:

2
0.9 0.049999 0.05 0.000001

output:

1.457509949996

result:

ok found '1.45751', expected '1.45751', error '0.00000'

Test #2:

score: 0
Accepted
time: 105ms
memory: 11168kb

input:

20
0.25 0.25 0.25 0.25

output:

39.99999999999999

result:

ok found '40.00000', expected '40.00000', error '0.00000'

Test #3:

score: 0
Accepted
time: 91ms
memory: 10916kb

input:

19
0.5 0.3 0.08615 0.11385

output:

32.000055102909144

result:

ok found '32.00006', expected '32.00006', error '0.00000'

Test #4:

score: 0
Accepted
time: 88ms
memory: 11112kb

input:

19
0.255 0.265 0.235 0.245

output:

37.99434466137963

result:

ok found '37.99434', expected '37.99435', error '0.00000'

Test #5:

score: 0
Accepted
time: 104ms
memory: 10976kb

input:

20
0.066667 0.133333 0.266667 0.533333

output:

32.84888480209875

result:

ok found '32.84888', expected '32.84889', error '0.00000'

Test #6:

score: 0
Accepted
time: 102ms
memory: 11180kb

input:

20
0.27 0.26 0.24 0.23

output:

39.97002442307791

result:

ok found '39.97002', expected '39.97002', error '0.00000'

Test #7:

score: 0
Accepted
time: 118ms
memory: 11020kb

input:

20
0.5 0.2 0.175 0.125

output:

35.617733235788144

result:

ok found '35.61773', expected '35.61773', error '0.00000'

Test #8:

score: 0
Accepted
time: 15ms
memory: 10740kb

input:

2
0.9 0.05 0.049999 0.000001

output:

1.457509949996

result:

ok found '1.45751', expected '1.45751', error '0.00000'

Test #9:

score: 0
Accepted
time: 14ms
memory: 10740kb

input:

3
0.25 0.25 0.25 0.25

output:

6.0

result:

ok found '6.00000', expected '6.00000', error '0.00000'

Test #10:

score: 0
Accepted
time: 9ms
memory: 10692kb

input:

9
0.25 0.25 0.25 0.25

output:

18.0

result:

ok found '18.00000', expected '18.00000', error '0.00000'

Test #11:

score: 0
Accepted
time: 18ms
memory: 10680kb

input:

9
0.1 0.4 0.3 0.2

output:

16.645985578999984

result:

ok found '16.64599', expected '16.64599', error '0.00000'

Test #12:

score: 0
Accepted
time: 100ms
memory: 10932kb

input:

20
0.56 0.1 0.01 0.33

output:

27.926967193579657

result:

ok found '27.92697', expected '27.92697', error '0.00000'

Test #13:

score: 0
Accepted
time: 15ms
memory: 10748kb

input:

1
0.5 0.25 0.125 0.125

output:

1.75

result:

ok found '1.75000', expected '1.75000', error '0.00000'

Test #14:

score: 0
Accepted
time: 14ms
memory: 10752kb

input:

2
0.5 0.25 0.125 0.125

output:

3.5

result:

ok found '3.50000', expected '3.50000', error '0.00000'

Test #15:

score: 0
Accepted
time: 14ms
memory: 10744kb

input:

3
0.5 0.25 0.125 0.125

output:

5.25

result:

ok found '5.25000', expected '5.25000', error '0.00000'

Test #16:

score: 0
Accepted
time: 22ms
memory: 10744kb

input:

11
0.5 0.25 0.125 0.125

output:

19.249999999999996

result:

ok found '19.25000', expected '19.25000', error '0.00000'

Test #17:

score: 0
Accepted
time: 7ms
memory: 10564kb

input:

1
0.403 0.199 0.199 0.199

output:

1.995

result:

ok found '1.99500', expected '1.99500', error '0.00000'

Test #18:

score: 0
Accepted
time: 14ms
memory: 10648kb

input:

1
0.199 0.403 0.199 0.199

output:

1.995

result:

ok found '1.99500', expected '1.99500', error '0.00000'

Test #19:

score: 0
Accepted
time: 14ms
memory: 10744kb

input:

1
0.199 0.199 0.403 0.199

output:

1.995

result:

ok found '1.99500', expected '1.99500', error '0.00000'

Test #20:

score: 0
Accepted
time: 3ms
memory: 10744kb

input:

1
0.199 0.199 0.199 0.403

output:

1.995

result:

ok found '1.99500', expected '1.99500', error '0.00000'

Test #21:

score: 0
Accepted
time: 11ms
memory: 10628kb

input:

4
0.4 0.25 0.24 0.11

output:

7.525134570000002

result:

ok found '7.52513', expected '7.52513', error '0.00000'

Test #22:

score: 0
Accepted
time: 15ms
memory: 10628kb

input:

4
0.25 0.4 0.24 0.11

output:

7.525134570000002

result:

ok found '7.52513', expected '7.52513', error '0.00000'

Test #23:

score: 0
Accepted
time: 7ms
memory: 10676kb

input:

4
0.25 0.24 0.4 0.11

output:

7.525134570000002

result:

ok found '7.52513', expected '7.52513', error '0.00000'

Test #24:

score: 0
Accepted
time: 15ms
memory: 10740kb

input:

4
0.25 0.24 0.11 0.4

output:

7.525134570000002

result:

ok found '7.52513', expected '7.52513', error '0.00000'

Test #25:

score: 0
Accepted
time: 15ms
memory: 10676kb

input:

4
0.0001 0.0002 0.00034 0.99936

output:

1.0089885151330946

result:

ok found '1.00899', expected '1.00899', error '0.00000'

Test #26:

score: 0
Accepted
time: 12ms
memory: 10564kb

input:

4
0.99936 0.00034 0.0002 0.0001

output:

1.0089885151330946

result:

ok found '1.00899', expected '1.00899', error '0.00000'

Test #27:

score: 0
Accepted
time: 14ms
memory: 10624kb

input:

4
0.00034 0.99936 0.0002 0.0001

output:

1.0089885151330946

result:

ok found '1.00899', expected '1.00899', error '0.00000'

Test #28:

score: 0
Accepted
time: 109ms
memory: 10880kb

input:

20
0.000001 0.999997 0.000001 0.000001

output:

1.0003570083839806

result:

ok found '1.00036', expected '1.00036', error '0.00000'

Test #29:

score: 0
Accepted
time: 35ms
memory: 10728kb

input:

15
0.000001 0.000001 0.999997 0.000001

output:

1.0002520044579841

result:

ok found '1.00025', expected '1.00025', error '0.00000'

Test #30:

score: 0
Accepted
time: 69ms
memory: 10940kb

input:

18
0.01 0.345 0.345 0.3

output:

29.675058743431805

result:

ok found '29.67506', expected '29.67506', error '0.00000'

Test #31:

score: 0
Accepted
time: 57ms
memory: 11008kb

input:

17
0.13 0.35 0.13 0.39

output:

31.05683615874624

result:

ok found '31.05684', expected '31.05684', error '0.00000'

Test #32:

score: 0
Accepted
time: 103ms
memory: 11056kb

input:

20
0.14 0.33 0.14 0.39

output:

37.0670968885939

result:

ok found '37.06710', expected '37.06710', error '0.00000'

Test #33:

score: 0
Accepted
time: 112ms
memory: 10976kb

input:

20
0.125001 0.25 0.5 0.124999

output:

35.000000000000256

result:

ok found '35.00000', expected '35.00000', error '0.00000'

Test #34:

score: 0
Accepted
time: 106ms
memory: 10924kb

input:

20
0.01 0.34503 0.34503 0.29994

output:

32.96720352534544

result:

ok found '32.96720', expected '32.96720', error '0.00000'

Test #35:

score: 0
Accepted
time: 112ms
memory: 11068kb

input:

20
0.4 0.2 0.3 0.1

output:

36.959297167069415

result:

ok found '36.95930', expected '36.95930', error '0.00000'

Test #36:

score: 0
Accepted
time: 113ms
memory: 11036kb

input:

20
0.01 0.02 0.03 0.94

output:

8.324709688145461

result:

ok found '8.32471', expected '8.32471', error '0.00000'

Test #37:

score: 0
Accepted
time: 110ms
memory: 10940kb

input:

20
0.991 0.003 0.003 0.003

output:

2.121381821746063

result:

ok found '2.12138', expected '2.12138', error '0.00000'

Test #38:

score: 0
Accepted
time: 107ms
memory: 10916kb

input:

20
0.495 0.005 0.495 0.005

output:

21.67540136477302

result:

ok found '21.67540', expected '21.67540', error '0.00000'

Test #39:

score: 0
Accepted
time: 102ms
memory: 10996kb

input:

20
0.492 0.008 0.493 0.007

output:

22.322928144765687

result:

ok found '22.32293', expected '22.32293', error '0.00000'

Test #40:

score: 0
Accepted
time: 102ms
memory: 11044kb

input:

20
0.032 0.051 0.023 0.894

output:

12.985654969505523

result:

ok found '12.98565', expected '12.98565', error '0.00000'

Test #41:

score: 0
Accepted
time: 103ms
memory: 10996kb

input:

20
0.002 0.01 0.09 0.898

output:

10.761968792600772

result:

ok found '10.76197', expected '10.76197', error '0.00000'

Test #42:

score: 0
Accepted
time: 117ms
memory: 10880kb

input:

20
0.91 0.03 0.03 0.03

output:

11.642446903927866

result:

ok found '11.64245', expected '11.64245', error '0.00000'