結果

問題 No.967 引き算をして門松列(その2)
ユーザー zer0zer0
提出日時 2020-01-13 21:57:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,486 bytes
コンパイル時間 138 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 10,952 KB
最終ジャッジ日時 2023-08-24 16:29:01
合計ジャッジ時間 1,618 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,104 KB
testcase_01 AC 17 ms
8,032 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def midfind(midlst):
    global maxt
    global mint
    midt = 0
    if midlst.count(maxt) == 2:
        midt = maxt
    else:
        midt = mint
    return midt

def minans(anslst):
    ans = 10 ** 9
    ans = min(ans, 2 * anslst[0] + anslst[-1])
    ans = min(ans, 2 * anslst[-1] + anslst[0])
    ans = min(ans, 2 * anslst[1] + anslst[0])
    ans = min(ans, 2 * anslst[1] + anslst[-1])
    return ans

T = int(input())
abclst = [list(map(int, input().split())) for _ in range(T)]

for i in range(T):
    maxt = max(abclst[i][:3])
    mint = min(abclst[i][:3])
    midt = 0
    ans = 10 ** 9
    if abclst[i][0:3].count(abclst[i][0]) == 3:
        if abclst[i][0] >= 3:
            tmplist = abclst[i][3:]
            tmplist.sort()
            ans = minans(abclst[i][3:])
            print(ans)
        else:
            print(-1)
        continue

    for j in range(3):
        if abclst[i][j] != maxt and abclst[i][j] != mint:
            midt = abclst[i][j]
            if j == 0 or j == 2:
                ans = 0
            break
    if midt == 0:
        midt = midfind(abclst[i][:3])
    if ans == 0:
        print(ans)
    else:
        tmp1 = maxt - midt + 1
        if maxt - tmp1 == mint:
            tmp1 += 1
        if maxt - tmp1 > 0:
            ans = tmp1 * abclst[i][3]
        tmp2 = midt - mint + 1
        if midt - tmp2 > 0:
            ans = min(ans, tmp2 * abclst[i][4])
        if ans == 10 ** 9:
            print(-1)
        else:
            print(ans)
0