結果

問題 No.1715 Dinner 2
ユーザー HydruHydru
提出日時 2021-10-22 23:05:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 777 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 81,804 KB
実行使用メモリ 72,564 KB
最終ジャッジ日時 2023-10-24 14:40:51
合計ジャッジ時間 3,352 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,532 KB
testcase_01 AC 39 ms
53,532 KB
testcase_02 AC 38 ms
53,532 KB
testcase_03 AC 35 ms
53,532 KB
testcase_04 AC 37 ms
53,532 KB
testcase_05 AC 35 ms
53,532 KB
testcase_06 AC 36 ms
53,532 KB
testcase_07 AC 38 ms
53,532 KB
testcase_08 AC 36 ms
53,532 KB
testcase_09 AC 36 ms
53,532 KB
testcase_10 AC 35 ms
53,532 KB
testcase_11 AC 84 ms
70,416 KB
testcase_12 AC 88 ms
70,484 KB
testcase_13 AC 90 ms
70,464 KB
testcase_14 AC 87 ms
70,484 KB
testcase_15 AC 91 ms
70,488 KB
testcase_16 AC 81 ms
70,412 KB
testcase_17 AC 72 ms
68,368 KB
testcase_18 AC 36 ms
53,532 KB
testcase_19 AC 35 ms
53,532 KB
testcase_20 AC 35 ms
53,532 KB
testcase_21 AC 34 ms
53,532 KB
testcase_22 AC 35 ms
53,532 KB
testcase_23 AC 37 ms
53,532 KB
testcase_24 AC 36 ms
53,532 KB
testcase_25 AC 51 ms
63,936 KB
testcase_26 AC 50 ms
63,912 KB
testcase_27 AC 52 ms
63,936 KB
testcase_28 AC 51 ms
63,932 KB
testcase_29 AC 51 ms
63,936 KB
testcase_30 AC 50 ms
63,928 KB
testcase_31 AC 51 ms
63,924 KB
testcase_32 AC 102 ms
72,564 KB
testcase_33 AC 101 ms
72,552 KB
testcase_34 AC 99 ms
72,552 KB
testcase_35 AC 97 ms
70,484 KB
testcase_36 AC 38 ms
53,532 KB
testcase_37 AC 36 ms
53,532 KB
testcase_38 AC 35 ms
53,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,d=map(int,input().split())
food=[]
for _ in range(n):
    p,q=map(int,input().split())
    food.append([-p,q,q-p])
food.sort()
las=food[-1][0]
las2=food[-2][0]
ans=-10**9+1
for i in range(n):
    for j in range(n):
        if i==j:
            continue
        T=food[i][2]+food[j][2]
        tmp=min(food[i][0],food[i][2]+food[j][0])
        if T<0:
            if d%2==0:
                if i!=n-1:
                    tmp=T*(d//2-1)+min(food[i][0],food[i][2]+las)
                else:
                    tmp=T*(d//2-1)+min(food[i][0],food[i][2]+las2)
            else:
                if j!=n-1:
                    tmp=T*((d-1)//2)+min(-food[j][1],las)
                else:
                    tmp=T*((d-1)//2)+min(-food[j][1],las2)
        ans=max(ans,tmp)
print(ans)
0