結果
| 問題 |
No.31 悪のミックスジュース
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-29 17:21:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,387 bytes |
| コンパイル時間 | 172 ms |
| コンパイル使用メモリ | 82,160 KB |
| 実行使用メモリ | 58,088 KB |
| 最終ジャッジ日時 | 2024-09-29 12:43:54 |
| 合計ジャッジ時間 | 1,902 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 WA * 9 |
ソースコード
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()