Submission #35924245


Source Code Expand

Copy
def D(N, K, A):
dp = [0] * (N + 1)
for i in range(N + 1):
for a in A:
if a > i: break
dp[i] = max(dp[i], i - dp[i - a])
return dp[N]
N, K = map(int, input().split())
*A, = map(int, input().split())
print(D(N, K, A))
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
def D(N, K, A):
    dp = [0] * (N + 1)
    
    for i in range(N + 1):
        for a in A:
            if a > i: break
            dp[i] = max(dp[i], i - dp[i - a])
    return dp[N]
 
N, K = map(int, input().split())
*A, = map(int, input().split())
print(D(N, K, A))

Submission Info

Submission Time
Task D - Stones
User arakaki_tokyo
Language PyPy3 (7.3.0)
Score 400
Code Size 277 Byte
Status AC
Exec Time 69 ms
Memory 72840 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 30
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
hand_01.txt AC 69 ms 61628 KB
hand_02.txt AC 49 ms 63412 KB
hand_03.txt AC 48 ms 61616 KB
random_01.txt AC 60 ms 66796 KB
random_02.txt AC 58 ms 66472 KB
random_03.txt AC 57 ms 66060 KB
random_04.txt AC 59 ms 66836 KB
random_05.txt AC 62 ms 66792 KB
random_06.txt AC 58 ms 66244 KB
random_07.txt AC 57 ms 66852 KB
random_08.txt AC 59 ms 65900 KB
random_09.txt AC 61 ms 66400 KB
random_10.txt AC 57 ms 66096 KB
random_11.txt AC 60 ms 66504 KB
random_12.txt AC 53 ms 65768 KB
random_13.txt AC 61 ms 66684 KB
random_14.txt AC 49 ms 61392 KB
random_15.txt AC 60 ms 66168 KB
random_16.txt AC 56 ms 66368 KB
random_17.txt AC 61 ms 66096 KB
random_18.txt AC 56 ms 64832 KB
random_19.txt AC 59 ms 65728 KB
random_20.txt AC 54 ms 65156 KB
random_21.txt AC 66 ms 72840 KB
random_22.txt AC 55 ms 66376 KB
random_23.txt AC 67 ms 72684 KB
random_24.txt AC 60 ms 66364 KB
sample_01.txt AC 49 ms 61668 KB
sample_02.txt AC 51 ms 61544 KB
sample_03.txt AC 57 ms 66612 KB


2025-04-08 (Tue)
15:04:04 +00:00