結果

問題 No.617 Nafmo、買い出しに行く
ユーザー Mille0x1CMille0x1C
提出日時 2019-12-09 02:41:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,251 ms / 2,000 ms
コード長 2,068 bytes
コンパイル時間 405 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 77,476 KB
最終ジャッジ日時 2023-09-01 22:06:49
合計ジャッジ時間 14,505 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
75,972 KB
testcase_01 AC 72 ms
71,172 KB
testcase_02 AC 92 ms
76,696 KB
testcase_03 AC 144 ms
77,296 KB
testcase_04 AC 74 ms
71,316 KB
testcase_05 AC 205 ms
77,428 KB
testcase_06 AC 1,241 ms
77,308 KB
testcase_07 AC 1,240 ms
77,236 KB
testcase_08 AC 71 ms
71,164 KB
testcase_09 AC 73 ms
71,336 KB
testcase_10 AC 1,228 ms
77,448 KB
testcase_11 AC 1,244 ms
77,332 KB
testcase_12 AC 1,250 ms
77,312 KB
testcase_13 AC 1,230 ms
77,320 KB
testcase_14 AC 1,251 ms
77,476 KB
testcase_15 AC 927 ms
77,264 KB
testcase_16 AC 932 ms
77,272 KB
testcase_17 AC 931 ms
77,376 KB
testcase_18 AC 73 ms
71,340 KB
testcase_19 AC 73 ms
71,212 KB
testcase_20 AC 72 ms
71,356 KB
testcase_21 AC 71 ms
71,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from __future__ import print_function

import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd

# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace

# from queue import PriorityQueue as pq

# def reduce(p, q):
#     common = fractions.gcd(p, q)
#     return (p//common , q//common )
# # from itertools import accumulate
# # from collections import deque

# from operator import mul
# from functools import reduce

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

# import random

def main():
    num_products, power_me = map(int, input().strip().split())
    l_weight=[]
    for i in range(num_products):
        a = int(input().strip())
        l_weight.append(a)

    ans=0
    for case in range(2 ** num_products):     # 場合ループ # nは人とかモノとかの個数
        l_bin_products = list(map(int,(format(case,'b').zfill(num_products))))
        # eprint("l_bin_products ",end=": ")
        # eprint(l_bin_products)

        #flag=0

        temp_ans=0
        Pow=power_me
        for index_products in range(num_products):      # 人とかモノとかループ
            if l_bin_products[index_products]==1:    # その桁がyesだと仮定している場合
               Pow-=l_weight[index_products]
               if Pow<0:
                   break
               temp_ans+=l_weight[index_products]
            else:
                pass
        ans=max(ans,temp_ans)
    print(ans)
    return

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