結果

問題 No.967 引き算をして門松列(その2)
ユーザー maspymaspy
提出日時 2020-01-13 20:38:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 827 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 11,012 KB
実行使用メモリ 12,036 KB
最終ジャッジ日時 2023-08-23 13:09:17
合計ジャッジ時間 1,344 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,244 KB
testcase_01 AC 16 ms
8,352 KB
testcase_02 AC 16 ms
8,340 KB
testcase_03 AC 25 ms
8,648 KB
testcase_04 AC 25 ms
8,632 KB
testcase_05 AC 26 ms
9,100 KB
testcase_06 AC 27 ms
9,316 KB
testcase_07 AC 27 ms
9,100 KB
testcase_08 AC 37 ms
10,456 KB
testcase_09 AC 46 ms
11,640 KB
testcase_10 AC 49 ms
12,036 KB
testcase_11 AC 47 ms
10,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

T = int(readline())
m = map(int,read().split())
ABCXYZ = zip(m,m,m,m,m,m)
INF = 10 ** 30

def type_231(A,B,C,X,Y,Z):
    a = B - 1
    if a > A:
        a = A
    c = a - 1
    if c > C:
        c = C
    if c <= 0:
        return INF
    return (A - a) * X + (C - c) * Z

def type_213(A,B,C,X,Y,Z):
    a = C - 1
    if a > A:
        a = A
    b = a - 1
    if b > B:
        b = B
    if b <= 0:
        return INF
    return (A - a) * X + (B - b) * Y

def solve(A,B,C,X,Y,Z):
    x = min(
        type_231(A,B,C,X,Y,Z), type_231(C,B,A,Z,Y,X),
        type_213(A,B,C,X,Y,Z), type_213(C,B,A,Z,Y,X))
    return x if x < INF else -1

answer = [solve(*args) for args in ABCXYZ]
print('\n'.join(map(str,answer)))
0