結果

問題 No.31 悪のミックスジュース
ユーザー Mao-betaMao-beta
提出日時 2024-02-29 17:21:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,387 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 57,832 KB
最終ジャッジ日時 2024-02-29 17:22:01
合計ジャッジ時間 2,355 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 45 ms
57,832 KB
testcase_05 AC 47 ms
57,832 KB
testcase_06 AC 43 ms
55,752 KB
testcase_07 AC 48 ms
57,832 KB
testcase_08 AC 47 ms
57,832 KB
testcase_09 WA -
testcase_10 AC 46 ms
55,752 KB
testcase_11 WA -
testcase_12 AC 46 ms
57,832 KB
testcase_13 AC 44 ms
55,752 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
import bisect
from heapq import heapify, heappop, heappush
from collections import deque, defaultdict, Counter
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD99 = 998244353

input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
SMI = lambda: input().split()
SLI = lambda: list(SMI())
EI = lambda m: [NLI() for _ in range(m)]


def main():
    N, V = NMI()
    C = NLI()
    X = list(accumulate(C))
    Y = list(range(1, N+1))
    ans = X[-1]
    V -= Y[-1]
    XY = [[x, y] for x, y in zip(X, Y)]

    from functools import cmp_to_key

    def cmp(a, b):
        ax, ay = a
        bx, by = b
        if ax * by < bx * ay:
            return -1
        elif ax * by > bx * ay:
            return 1
        else:
            if bx > by:
                return -1
            elif bx < by:
                return 1
            else:
                return 0


    while V > 0:
        for i in range(N):
            XY[i][1] = min(XY[i][1], V)
        XY = sorted(XY, key=cmp_to_key(cmp))
        # print(XY)
        x, y = XY[0]
        k, r = divmod(V, y)
        ans += x * k
        V -= y * k

    print(ans)


if __name__ == "__main__":
    main()
0