結果

問題 No.617 Nafmo、買い出しに行く
ユーザー naimonon77naimonon77
提出日時 2018-01-17 10:27:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 427 ms / 2,000 ms
コード長 741 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 10,544 KB
実行使用メモリ 10,996 KB
最終ジャッジ日時 2023-08-25 20:31:57
合計ジャッジ時間 5,866 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
10,756 KB
testcase_01 AC 39 ms
10,752 KB
testcase_02 AC 39 ms
10,756 KB
testcase_03 AC 65 ms
10,940 KB
testcase_04 AC 38 ms
10,912 KB
testcase_05 AC 88 ms
10,792 KB
testcase_06 AC 422 ms
10,876 KB
testcase_07 AC 424 ms
10,984 KB
testcase_08 AC 38 ms
10,752 KB
testcase_09 AC 39 ms
10,996 KB
testcase_10 AC 426 ms
10,952 KB
testcase_11 AC 426 ms
10,728 KB
testcase_12 AC 424 ms
10,896 KB
testcase_13 AC 425 ms
10,768 KB
testcase_14 AC 427 ms
10,816 KB
testcase_15 AC 418 ms
10,980 KB
testcase_16 AC 405 ms
10,884 KB
testcase_17 AC 411 ms
10,940 KB
testcase_18 AC 38 ms
10,756 KB
testcase_19 AC 38 ms
10,812 KB
testcase_20 AC 39 ms
10,908 KB
testcase_21 AC 38 ms
10,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

from queue import Queue
import sys
import subprocess
import json
import time
import math
import re
#import sqlite3
import random
#import numpy as np
#from sklearn.datasets import fetch_mldata
#from statistics import mean, median, variance, stdev
#from chainer import cuda, Variable, FunctionSet, optimizers
#import chainer.functions as F

def ans(i, cur_weight):
    if (i == N):
        if (cur_weight <= K):
            return cur_weight
        else:
            return 0

    return max( ans(i+1, cur_weight+A[i]), ans(i+1, cur_weight) )

N, K = map(int, input().split())
A = [int(input()) for i in range(N)]
# print("N =", N)
# print("K =", K)
# for i in range(N):
#     print("A[i] =", A[i])
print(ans(0, 0))

0