結果

問題 No.453 製薬会社
ユーザー Yuki_UtaaiYuki_Utaai
提出日時 2018-03-20 21:49:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,652 bytes
コンパイル時間 635 ms
コンパイル使用メモリ 87,328 KB
実行使用メモリ 85,884 KB
最終ジャッジ日時 2023-09-06 23:31:16
合計ジャッジ時間 15,315 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,060 ms
84,524 KB
testcase_01 AC 1,069 ms
85,344 KB
testcase_02 WA -
testcase_03 AC 1,058 ms
84,448 KB
testcase_04 WA -
testcase_05 AC 761 ms
83,364 KB
testcase_06 AC 926 ms
83,876 KB
testcase_07 WA -
testcase_08 AC 928 ms
83,904 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import random	
import math

def annealing_initialze():
  cost_max=0
  for ii in range(3000):
    for jj in range(3000):
        vec=[(C+D)*ii/4000,(C+D)*jj/4000]
        stock_c=C-0.75*vec[0]-2/7*vec[1]
        stock_d=D-0.25*vec[0]-5/7*vec[1]
        if stock_c>=0 and stock_d>=0:
            if cost_max<= costf(vec):
                cost_max= costf(vec)
                vect=vec[:]
  return vect


def annealingoptimize(T=12000, cool=0.99993, step=0.005):
    dimension=2
    
    vec=[A,B]
    newvec = vec[:]
    while T > 0.0001:
        i = random.randint(0, dimension-1)
        dir = random.random()
        dir = (dir - 0.5) * step

        if i==0:
            stock_c=C-0.75*(vec[0]+dir)-2/7*vec[1]
            stock_d=D-0.25*(vec[0]+dir)-5/7*vec[1]
            if stock_c<0 or stock_d<0 or vec[0]+dir<0:
                newvec[i] = vec[i]
            else:
                newvec[i] = vec[i] + dir

        else:
            stock_c=C-0.75*vec[0]-2/7*(vec[1]+dir)
            stock_d=D-0.25*vec[0]-5/7*(vec[1]+dir)
            if stock_c<0 or stock_d<0 or vec[1]+dir<0:
                newvec[i] = vec[i]
            else:
                newvec[i] = vec[i] + dir

        newcost = costf(newvec)
        cost = costf(vec)
        p = pow(math.e, -abs(newcost - cost) / T)
        if(newcost > cost or random.random() < p):
            vec[i] = newvec[i]
        T = T * cool
    return vec
	
def costf(vec):
    return (1000*vec[0]+2000*vec[1])

C,D=[int(i) for i in input().split()]
A,B=annealing_initialze()
#print(A,B)


ans=0
k_min=[]
for i in range(3):
    kkk=annealingoptimize()
    cost=costf(kkk)
    ans=max(ans,cost)
print(ans)
0