提出 #76662384


ソースコード 拡げる

def f(a, b, x, y):
  if x < 0: return f(a, b, -x, y)
  if y < 0: return f(a, b, x, -y)
  if x == 0:
    # if y == 0: return 0
    c = y//2
    n = c*4+3*(y%2)
    m = c*4+1*(y%2)
    return min(b*(y%2)+c*(a+b), a*n, b*m)
  if y == 0:
    c = x//2
    n = c*4+3*(x%2)
    m = c*4+1*(x%2)
    return min(a*(x%2)+c*(a+b), b*n, a*m)
  if x > y: return f(b, a, y, x)
  # x <= y
  return f(a, b, 0, y-x)+2*x*min(a, b)
t = int(input())
for i in range(t):
  a, b, x, y = map(int, input().split())
  print(f(a, b, x, y))

提出情報

提出日時
問題 E - Alternating Costs
ユーザ suisankafe2
言語 Python (CPython 3.13.7)
得点 450
コード長 531 Byte
結果 AC
実行時間 556 ms
メモリ 9332 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 450 / 450
結果
AC × 1
AC × 33
セット名 テストケース
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 01_handmade_10.txt, 01_handmade_11.txt, 01_handmade_12.txt, 01_handmade_13.txt, 01_handmade_14.txt, 01_handmade_15.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 10 ms 9204 KiB
01_handmade_00.txt AC 462 ms 9124 KiB
01_handmade_01.txt AC 466 ms 9312 KiB
01_handmade_02.txt AC 470 ms 9204 KiB
01_handmade_03.txt AC 466 ms 9204 KiB
01_handmade_04.txt AC 466 ms 9204 KiB
01_handmade_05.txt AC 487 ms 9180 KiB
01_handmade_06.txt AC 488 ms 9204 KiB
01_handmade_07.txt AC 508 ms 9312 KiB
01_handmade_08.txt AC 489 ms 9272 KiB
01_handmade_09.txt AC 499 ms 9276 KiB
01_handmade_10.txt AC 501 ms 9276 KiB
01_handmade_11.txt AC 489 ms 9296 KiB
01_handmade_12.txt AC 494 ms 9272 KiB
01_handmade_13.txt AC 499 ms 9124 KiB
01_handmade_14.txt AC 509 ms 9272 KiB
01_handmade_15.txt AC 526 ms 9312 KiB
02_random_00.txt AC 554 ms 9180 KiB
02_random_01.txt AC 556 ms 9180 KiB
02_random_02.txt AC 549 ms 9332 KiB
02_random_03.txt AC 546 ms 9280 KiB
02_random_04.txt AC 537 ms 9272 KiB
02_random_05.txt AC 529 ms 9200 KiB
02_random_06.txt AC 551 ms 9296 KiB
02_random_07.txt AC 541 ms 9204 KiB
02_random_08.txt AC 543 ms 9288 KiB
02_random_09.txt AC 542 ms 9288 KiB
02_random_10.txt AC 541 ms 9288 KiB
02_random_11.txt AC 547 ms 9108 KiB
02_random_12.txt AC 548 ms 9304 KiB
02_random_13.txt AC 541 ms 9288 KiB
02_random_14.txt AC 549 ms 9204 KiB
02_random_15.txt AC 548 ms 9180 KiB