結果

問題 No.5008 [Cherry Alpha] Discrete Pendulum with Air Resistance
ユーザー Akijin_007Akijin_007
提出日時 2022-10-15 00:34:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,936 ms / 2,000 ms
コード長 2,749 bytes
コンパイル時間 260 ms
実行使用メモリ 86,764 KB
スコア 1,146,929,834,277,131
最終ジャッジ日時 2022-10-15 00:36:32
合計ジャッジ時間 104,659 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,889 ms
85,828 KB
testcase_01 AC 1,885 ms
85,652 KB
testcase_02 AC 1,886 ms
86,516 KB
testcase_03 AC 1,899 ms
85,240 KB
testcase_04 AC 1,890 ms
85,428 KB
testcase_05 AC 1,893 ms
85,592 KB
testcase_06 AC 1,887 ms
85,536 KB
testcase_07 AC 1,889 ms
85,524 KB
testcase_08 AC 1,892 ms
85,972 KB
testcase_09 AC 1,887 ms
86,724 KB
testcase_10 AC 1,892 ms
85,952 KB
testcase_11 AC 1,890 ms
85,672 KB
testcase_12 AC 1,894 ms
86,244 KB
testcase_13 AC 1,892 ms
85,460 KB
testcase_14 AC 1,898 ms
85,200 KB
testcase_15 AC 1,936 ms
85,540 KB
testcase_16 AC 1,893 ms
86,188 KB
testcase_17 AC 1,884 ms
86,072 KB
testcase_18 AC 1,891 ms
85,600 KB
testcase_19 AC 1,886 ms
85,616 KB
testcase_20 AC 1,887 ms
85,784 KB
testcase_21 AC 1,891 ms
85,472 KB
testcase_22 AC 1,890 ms
86,488 KB
testcase_23 AC 1,886 ms
85,964 KB
testcase_24 AC 1,889 ms
86,180 KB
testcase_25 AC 1,886 ms
86,224 KB
testcase_26 AC 1,890 ms
86,764 KB
testcase_27 AC 1,891 ms
86,104 KB
testcase_28 AC 1,888 ms
85,456 KB
testcase_29 AC 1,891 ms
86,172 KB
testcase_30 AC 1,886 ms
85,444 KB
testcase_31 AC 1,899 ms
85,508 KB
testcase_32 AC 1,885 ms
85,528 KB
testcase_33 AC 1,885 ms
86,228 KB
testcase_34 AC 1,885 ms
85,836 KB
testcase_35 AC 1,895 ms
85,988 KB
testcase_36 AC 1,888 ms
86,044 KB
testcase_37 AC 1,901 ms
86,036 KB
testcase_38 AC 1,887 ms
85,912 KB
testcase_39 AC 1,891 ms
86,500 KB
testcase_40 AC 1,886 ms
86,020 KB
testcase_41 AC 1,888 ms
85,888 KB
testcase_42 AC 1,886 ms
85,864 KB
testcase_43 AC 1,892 ms
85,264 KB
testcase_44 AC 1,900 ms
86,208 KB
testcase_45 AC 1,887 ms
85,920 KB
testcase_46 AC 1,892 ms
85,564 KB
testcase_47 AC 1,890 ms
85,776 KB
testcase_48 AC 1,891 ms
86,048 KB
testcase_49 AC 1,888 ms
85,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(t, B, M, E):
    u, v = divmod(B-M, E)
    a = time0(u, B, E)
    # print(a)
    if t < a:
        min1 = 0
        max1 = u+1
        while max1 - min1 > 1:
            h = (max1 + min1) // 2
            ha = time0(h-1, B, E)
            if ha > t:
                max1 = h
            else:
                min1 = h
        hmin = time0(min1-1, B, E)
        hmax = time0(min1, B, E)
        # print(min1, hmin, hmax)
        px = min(abs(t - hmin), abs(hmax - t))
        if min1 % 2 == 0:
            return px
        else:
            return -px
    else:
        p, q = divmod(t - a, 2*M)
        px = min(abs(t - (a + p*2*M)), abs(t - (a + (p+1)*2*M)))
        if (p + u + 1) % 2 == 0:
            return px
        else:
            return -px

def time0(times, B, E):
    return (times + 1) * (2 * B - times * E)

def score(B, M, E):
    Sconf = 0
    for u in T:
        a = 0
        x = [0] * N
        for i in range(N):
            x[i] = f(u, B[i], M[i], E[i])
        for i in range(N-1):
            for j in range(i+1, N):
                a += abs(x[i] - x[j]) / (B[i] + B[j])
        # print(x, a)
        Sconf += round(2 * 10 ** 7 * a / (N * (N - 1)))

    Sconf = round(Sconf / K)

    Scoop = 0
    for u in U:
        for i in range(N):
            x[i] = f(u, B[i], M[i], E[i])
        Scoop += 10 ** 7 / (((max(x) - min(x)) / 20 + 1) ** 0.5)

    Scoop = round(Scoop / K)
    # print(Sconf, Scoop)

    return Sconf * Scoop

def stdinput():
    N, K = map(int, input().split())
    T = list(map(int, input().split()))
    U = list(map(int, input().split()))
    return N, K, T, U

def randinput():
    N = 50
    K = 50
    delta = 200
    G = [0] * (2 * K + 1)
    i = random.randint(0, 1)
    F = [0] * (2 * K)
    while True:
        for i in range(2 * K):
            F[i] = random.random()
            if F[i] == 0:
                F[i] = random.random()
        for i in range(2*K):
            G[i+1] = round(G[i] + delta / F[i])
        if G[-1] <= 10 ** 9:
            break
    if i % 2 == 0:
        T = G[1::2]
        U = G[2::2]
    else:
        T = G[2::2]
        U = G[1::2]
    return N, K, T, U

import random
import time

# N, K, T, U = randinput()
N, K, T, U = stdinput()

ut = time.time()

NB = [0] * N
NM = [0] * N
NE = [0] * N

maxscore = 0

m = 3
# i = 0

while time.time() - ut < 1.8:
    # i += 1
    for i in range(N):
        NB[i] = random.randint(1, m)
        NM[i] = random.randint(1, NB[i])
        NE[i] = random.randint(1, m)
    sc = score(NB, NM, NE)
    if maxscore < sc:
        B = list(NB)
        M = list(NM)
        E = list(NE)
        maxscore = sc

# for i in range(N):
#     print(f(m, B[i], M[i], E[i]))
for i in range(N):
    print(B[i], M[i], E[i])
# print(i)



0