結果

問題 No.1715 Dinner 2
ユーザー wolgnikwolgnik
提出日時 2021-10-22 21:58:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,122 bytes
コンパイル時間 639 ms
コンパイル使用メモリ 81,620 KB
実行使用メモリ 68,292 KB
最終ジャッジ日時 2023-10-24 13:04:19
合計ジャッジ時間 3,325 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,432 KB
testcase_01 AC 39 ms
53,432 KB
testcase_02 AC 37 ms
53,432 KB
testcase_03 AC 37 ms
53,432 KB
testcase_04 AC 37 ms
53,432 KB
testcase_05 AC 37 ms
53,432 KB
testcase_06 AC 37 ms
53,432 KB
testcase_07 AC 37 ms
53,432 KB
testcase_08 AC 37 ms
53,432 KB
testcase_09 AC 36 ms
53,432 KB
testcase_10 WA -
testcase_11 AC 59 ms
66,244 KB
testcase_12 AC 55 ms
66,244 KB
testcase_13 AC 57 ms
68,292 KB
testcase_14 AC 56 ms
66,244 KB
testcase_15 AC 57 ms
68,292 KB
testcase_16 AC 55 ms
66,244 KB
testcase_17 AC 54 ms
66,240 KB
testcase_18 AC 47 ms
61,772 KB
testcase_19 AC 47 ms
61,772 KB
testcase_20 AC 41 ms
59,568 KB
testcase_21 AC 41 ms
59,564 KB
testcase_22 AC 46 ms
61,772 KB
testcase_23 AC 47 ms
61,772 KB
testcase_24 AC 47 ms
61,772 KB
testcase_25 AC 48 ms
61,772 KB
testcase_26 AC 47 ms
61,772 KB
testcase_27 AC 47 ms
61,772 KB
testcase_28 AC 48 ms
61,772 KB
testcase_29 AC 48 ms
61,772 KB
testcase_30 AC 48 ms
61,772 KB
testcase_31 AC 47 ms
61,772 KB
testcase_32 AC 56 ms
68,288 KB
testcase_33 AC 57 ms
68,292 KB
testcase_34 AC 57 ms
68,292 KB
testcase_35 AC 58 ms
68,292 KB
testcase_36 AC 37 ms
53,432 KB
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N, D = map(int, input().split())
a = []
b = []
t = []
for i in range(N):
  p, q = map(int, input().split())
  if p <= q: a.append((p, q, i))
  else: b.append((p, q, i))
  t.append((p, q))

s = set()

if len(a) >= 1:
  a.sort(key = lambda x: (x[0], -x[1]))
  s.add(a[0][2])

if len(a) >= 2:
  a.sort(key = lambda x: (x[0], -x[1]))
  s.add(a[1][2])

if len(a) >= 1:
  a.sort(key = lambda x: -x[1])
  s.add(a[0][2])

if len(a) >= 2:
  a.sort(key = lambda x: -x[1])
  s.add(a[1][2])

if len(b) >= 1:
  b.sort(key = lambda x: -x[1])
  s.add(b[0][2])

if len(b) >= 2:
  b.sort(key = lambda x: -x[1])
  s.add(b[1][2])

if len(b) >= 1:
  b.sort(key = lambda x: (x[0], -x[1]))
  s.add(b[0][2])

if len(b) >= 2:
  b.sort(key = lambda x: (x[0], -x[1]))
  s.add(b[1][2])

res = -10 ** 18
for i in s:
  for j in s:
    if i == j: continue
    tt = 0
    tres = 0
    for k in range(D):
      if k & 1:
        tt -= t[i][0]
        tres = min(tres, tt)
        tt += t[i][1]
      else:
        tt -= t[j][0]
        tres = min(tres, tt)
        tt += t[j][1]
    res = max(res, tres)


print(res)
0