Submission #2581895


Source Code Expand

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,k = LI()
    a = LI()
    if sum(a) < k:
        return -1
    dp = [inf] * (k+1)
    dp[0] = 0
    for c in a:
        for i in range(k-1,-1,-1):
            t = i + c
            if t > k:
                t = k
            if dp[t] > dp[i] + 1:
                dp[t] = dp[i] + 1

    return dp[k]




print(main())

Submission Info

Submission Time
Task A - Credits
User iehn
Language Python (3.4.3)
Score 100
Code Size 950 Byte
Status AC
Exec Time 49 ms
Memory 5460 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 18
Set Name Test Cases
All corner_10, corner_11, corner_12, corner_13, max_14, random_00, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, sample_00, sample_01, sample_02
Case Name Status Exec Time Memory
corner_10 AC 42 ms 5332 KB
corner_11 AC 42 ms 5336 KB
corner_12 AC 41 ms 5328 KB
corner_13 AC 41 ms 5332 KB
max_14 AC 49 ms 5332 KB
random_00 AC 41 ms 5332 KB
random_01 AC 41 ms 5328 KB
random_02 AC 41 ms 5336 KB
random_03 AC 41 ms 5456 KB
random_04 AC 41 ms 5336 KB
random_05 AC 43 ms 5456 KB
random_06 AC 41 ms 5456 KB
random_07 AC 41 ms 5456 KB
random_08 AC 42 ms 5336 KB
random_09 AC 41 ms 5332 KB
sample_00 AC 41 ms 5456 KB
sample_01 AC 41 ms 5460 KB
sample_02 AC 41 ms 5332 KB