結果

問題 No.617 Nafmo、買い出しに行く
ユーザー RyutoRyuto
提出日時 2017-12-17 17:02:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 361 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 71,532 KB
最終ジャッジ日時 2023-08-22 04:37:03
合計ジャッジ時間 3,022 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,264 KB
testcase_01 AC 72 ms
71,096 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 72 ms
71,164 KB
testcase_06 AC 72 ms
71,076 KB
testcase_07 AC 73 ms
71,020 KB
testcase_08 AC 72 ms
71,196 KB
testcase_09 AC 71 ms
70,964 KB
testcase_10 AC 72 ms
71,292 KB
testcase_11 AC 73 ms
71,260 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 71 ms
71,276 KB
testcase_16 AC 71 ms
71,092 KB
testcase_17 AC 73 ms
70,856 KB
testcase_18 AC 72 ms
70,960 KB
testcase_19 AC 71 ms
71,276 KB
testcase_20 AC 72 ms
71,288 KB
testcase_21 AC 71 ms
70,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python

indat = [int(x) for x in input().split()]
weights = []
for i in range(indat[0]):
    weights.append(int(input()))
weights.sort()
weights.reverse()

ans = 0
for weight in weights:
    ans += weight
    if ans == indat[1]:
        break
    elif ans > indat[1]:
        ans -= weight
        continue
    else:
        continue

print(ans)
0