結果

問題 No.2495 Three Sets
ユーザー mymelochanmymelochan
提出日時 2023-10-06 22:11:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,930 ms / 3,000 ms
コード長 2,046 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 87,352 KB
実行使用メモリ 131,396 KB
最終ジャッジ日時 2023-10-06 22:12:23
合計ジャッジ時間 63,868 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,813 ms
81,312 KB
testcase_01 AC 2,812 ms
81,320 KB
testcase_02 AC 2,813 ms
81,012 KB
testcase_03 AC 2,811 ms
81,492 KB
testcase_04 AC 2,813 ms
81,608 KB
testcase_05 AC 2,815 ms
81,788 KB
testcase_06 AC 2,812 ms
81,740 KB
testcase_07 AC 2,817 ms
80,820 KB
testcase_08 AC 2,812 ms
81,740 KB
testcase_09 AC 2,816 ms
81,600 KB
testcase_10 AC 2,815 ms
81,044 KB
testcase_11 AC 2,816 ms
81,232 KB
testcase_12 AC 2,812 ms
81,624 KB
testcase_13 AC 2,855 ms
96,816 KB
testcase_14 AC 2,890 ms
113,148 KB
testcase_15 AC 2,868 ms
97,912 KB
testcase_16 AC 2,927 ms
131,012 KB
testcase_17 AC 2,930 ms
131,396 KB
testcase_18 AC 2,814 ms
81,560 KB
testcase_19 AC 2,875 ms
129,856 KB
testcase_20 AC 2,875 ms
129,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#############################################################

import sys
sys.setrecursionlimit(10**7)

from heapq import heappop,heappush
from collections import deque,defaultdict,Counter
from bisect import bisect_left, bisect_right
from itertools import product,combinations,permutations

ipt = sys.stdin.readline

def iin():
    return int(ipt())
def lmin():
    return list(map(int,ipt().split()))

import random
import time
from math import exp

TL = 0.3
T0,T1 = 10000,1

MOD = 998244353
#############################################################

start_time = time.time()

NA,NB,NC = lmin()
A = lmin()
B = lmin()
C = lmin()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

SA = [0]
SB = [0]
SC = [0]

for a in A:
    SA.append(SA[-1]+a)
for b in B:
    SB.append(SB[-1]+b)
for c in C:
    SC.append(SC[-1]+c)

d = [(1,0,0),(-1,0,0),(0,1,0),(0,-1,0),(0,0,1),(0,0,-1)]

def calc_score(i,j,k):
    return SA[i]*j+SB[j]*k+SC[k]*i

ans = 0
while time.time() - start_time + TL <= 2.98:
    ca,cb,cc = random.randrange(NA),random.randrange(NB),random.randrange(NC)
    cur_time = 0
    cnt = 0

    score = calc_score(ca,cb,cc)

    tmp_start_time = time.time()
    while True:
        if cnt%100 == 0:
            cur_time = (time.time()-tmp_start_time)/TL
            if cur_time >= 1.0:
                break
        
        idx = random.randrange(6)
        da,db,dc = d[idx]
        na,nb,nc = da+ca,db+cb,dc+cc

        if na < 0 or na > NA or nb < 0 or nb > NB or nc < 0 or nc > NC:
            continue

        new_score = calc_score(na,nb,nc)

        d_score = new_score-score
        
        
        temp = T0**(1-cur_time)*T1**cur_time
        v = d_score/temp
        v = min(v,1.01)
        v = max(v,-20)

        if cur_time >= 0.95:
            if v >= 0:
                ca,cb,cc = na,nb,nc
                score = new_score
        else:
            if exp(v) > random.random():
                ca,cb,cc = na,nb,nc
                score = new_score
    
    ans = max(ans,score)

print(ans)
    

        
0