結果

問題 No.1715 Dinner 2
ユーザー mkawa2mkawa2
提出日時 2021-10-22 22:07:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,391 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 12,040 KB
実行使用メモリ 10,896 KB
最終ジャッジ日時 2023-10-24 13:18:33
合計ジャッジ時間 18,439 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,620 KB
testcase_01 AC 33 ms
10,620 KB
testcase_02 AC 33 ms
10,620 KB
testcase_03 AC 33 ms
10,620 KB
testcase_04 AC 33 ms
10,620 KB
testcase_05 WA -
testcase_06 AC 35 ms
10,620 KB
testcase_07 AC 34 ms
10,620 KB
testcase_08 AC 33 ms
10,620 KB
testcase_09 AC 32 ms
10,620 KB
testcase_10 AC 32 ms
10,620 KB
testcase_11 AC 1,174 ms
10,844 KB
testcase_12 AC 1,396 ms
10,868 KB
testcase_13 AC 1,620 ms
10,884 KB
testcase_14 AC 1,220 ms
10,852 KB
testcase_15 AC 1,474 ms
10,876 KB
testcase_16 AC 947 ms
10,832 KB
testcase_17 AC 629 ms
10,808 KB
testcase_18 AC 34 ms
10,684 KB
testcase_19 AC 34 ms
10,620 KB
testcase_20 AC 33 ms
10,620 KB
testcase_21 AC 33 ms
10,620 KB
testcase_22 AC 33 ms
10,620 KB
testcase_23 AC 33 ms
10,620 KB
testcase_24 AC 33 ms
10,620 KB
testcase_25 AC 46 ms
10,632 KB
testcase_26 AC 40 ms
10,628 KB
testcase_27 AC 47 ms
10,696 KB
testcase_28 AC 44 ms
10,632 KB
testcase_29 AC 42 ms
10,632 KB
testcase_30 AC 43 ms
10,632 KB
testcase_31 AC 44 ms
10,632 KB
testcase_32 AC 1,881 ms
10,896 KB
testcase_33 AC 1,862 ms
10,896 KB
testcase_34 AC 1,849 ms
10,896 KB
testcase_35 AC 1,856 ms
10,896 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 32 ms
10,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sre_constants
import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**19
# md = 998244353
md = 10**9+7

def solve(i, j):
    p1, q1 = pq[i]
    p2, q2 = pq[j]
    res = min(-p1+q1-p2, -p1)
    if d & 1:
        if p1 == pp[0]: a = (-p1+q1-p2+q2)*(d//2)-pp[1]
        else: a = (-p1+q1-p2+q2)*(d//2)-pp[0]
        res = min(res, a)
        a = (-p1+q1-p2+q2)*(d//2)-q2
        res = min(res, a)
    else:
        if p2 == pp[0]: a = (-p1+q1-p2+q2)*(d//2-1)-p1+q1-pp[1]
        else: a = (-p1+q1-p2+q2)*(d//2-1)-p1+q1-pp[0]
        res = min(res, a)
        a = (-p1+q1-p2+q2)*(d//2-1)-p1
        res = min(res, a)
    return res

n, d = LI()
pq = LLI(n)
pp = [p for p, q in pq]
pp.sort()

ans = -inf
for i in range(n):
    for j in range(n):
        if i == j: continue
        ans = max(ans, solve(i, j))

print(ans)
0