Submission #1175741


Source Code Expand

n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
ldp=[[0]*k for _ in xrange(n)]
rdp=[[0]*k for _ in xrange(n)]
for i in xrange(n):
    ldp[i][0]=True
    rdp[i][0]=True
    if a[i]<k:
        ldp[i][a[i]]=True
    if a[n-i-1]<k:
        rdp[i][a[n-1-i]]=True
for i in xrange(1,n):
    for j in xrange(k):
        if j-a[i]>=0:
            ldp[i][j]|=ldp[i-1][j-a[i]]|ldp[i-1][j]
        else:
            ldp[i][j]|=ldp[i-1][j]
        if j-a[n-1-i]>=0:
            rdp[i][j]|=rdp[i-1][j-a[n-1-i]]|rdp[i-1][j]
        else:
            rdp[i][j]|=rdp[i-1][j]
rsum=[[0]*k for _ in xrange(n)]
for i in xrange(n):
    for j in xrange(k):
        if j==0:
            rsum[i][j]=rdp[i][j]
        else:
            rsum[i][j]=rsum[i][j-1]+rdp[i][j]
cnt=0
for i in xrange(n):
    if k-a[i]<=0:
        cnt+=1
        continue
    for j in xrange(k):
        if i==0:
            left=0
        elif i==n-1:
            if ldp[i-1][j] and a[i]+j>=k:
                cnt+=1
                break
            continue
        else:
            if ldp[i-1][j]:
                left=j
            else:
                continue
        if k-a[i]-left<=0:
            cnt+=1
            break
        if rsum[n-2-i][k-1-left]-rsum[n-2-i][k-a[i]-left-1]:
            cnt+=1
            break
print n-cnt

Submission Info

Submission Time
Task D - No Need
User roto_37
Language PyPy2 (5.6.0)
Score 300
Code Size 1358 Byte
Status TLE
Exec Time 2184 ms
Memory 1286940 KB

Judge Result

Set Name Sample Subtask All
Score / Max Score 0 / 0 300 / 300 0 / 300
Status
AC × 3
AC × 26
AC × 35
TLE × 15
MLE × 1
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
Subtask 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 2_026.txt, 2_027.txt, 2_028.txt, 2_029.txt, 2_030.txt, 2_031.txt, 2_032.txt, 2_033.txt, 2_034.txt, 2_035.txt, 2_036.txt, 2_037.txt, 2_038.txt, 2_039.txt, 2_040.txt, 2_041.txt, 2_042.txt, 2_043.txt, 2_044.txt, 2_045.txt, 2_046.txt, 2_047.txt, 2_048.txt, 2_049.txt, 2_050.txt
Case Name Status Exec Time Memory
0_000.txt AC 33 ms 27116 KB
0_001.txt AC 55 ms 33004 KB
0_002.txt AC 34 ms 27884 KB
1_003.txt AC 33 ms 28524 KB
1_004.txt AC 33 ms 26988 KB
1_005.txt AC 33 ms 26988 KB
1_006.txt AC 55 ms 33004 KB
1_007.txt AC 48 ms 32876 KB
1_008.txt AC 97 ms 48748 KB
1_009.txt AC 103 ms 48668 KB
1_010.txt AC 74 ms 42652 KB
1_011.txt AC 36 ms 29548 KB
1_012.txt AC 74 ms 42652 KB
1_013.txt AC 36 ms 28396 KB
1_014.txt AC 36 ms 29676 KB
1_015.txt AC 93 ms 48620 KB
1_016.txt AC 52 ms 32620 KB
1_017.txt AC 49 ms 32620 KB
1_018.txt AC 55 ms 32540 KB
1_019.txt AC 81 ms 39580 KB
1_020.txt AC 60 ms 32876 KB
1_021.txt AC 80 ms 37740 KB
1_022.txt AC 64 ms 34284 KB
1_023.txt AC 63 ms 32748 KB
1_024.txt AC 96 ms 41756 KB
1_025.txt AC 100 ms 45468 KB
2_026.txt AC 36 ms 28780 KB
2_027.txt AC 61 ms 33644 KB
2_028.txt AC 59 ms 33516 KB
2_029.txt TLE 2182 ms 1273500 KB
2_030.txt TLE 2182 ms 1263644 KB
2_031.txt TLE 2182 ms 1276060 KB
2_032.txt AC 62 ms 33308 KB
2_033.txt TLE 2181 ms 1270428 KB
2_034.txt AC 57 ms 33388 KB
2_035.txt AC 56 ms 33388 KB
2_036.txt TLE 2181 ms 1272476 KB
2_037.txt AC 77 ms 37612 KB
2_038.txt AC 74 ms 37868 KB
2_039.txt AC 77 ms 38124 KB
2_040.txt TLE 2180 ms 1239068 KB
2_041.txt TLE 2154 ms 912796 KB
2_042.txt TLE 2178 ms 1206428 KB
2_043.txt TLE 2160 ms 927004 KB
2_044.txt TLE 2154 ms 904112 KB
2_045.txt MLE 1728 ms 659656 KB
2_046.txt TLE 2156 ms 923316 KB
2_047.txt TLE 2176 ms 1178524 KB
2_048.txt TLE 2183 ms 1286940 KB
2_049.txt TLE 2184 ms 1261212 KB
2_050.txt TLE 2181 ms 1261084 KB