Submission #1730694


Source Code Expand

#include <iostream>
#include <fstream>
using namespace std;
const int nmax=5025;
int dp[2][nmax][nmax];
int a[nmax],l[nmax],r[nmax];
int n,i,j,k,ind,n1,n2,ans;
bool check()
{
    ind=1;
    for(j=n1;j>=1;j--)
    {
        while(ind<=n2&&l[j]+r[ind]<k) ind++;
        ind--;
        if(l[j]+r[ind]>=k-a[i])
            return 1;
    }
    return 0;
}
int main()
{
    //freopen("data.in","r",stdin);
    cin>>n>>k;
    dp[0][0][0]=1;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        for(j=0;j<=k;j++)
            dp[0][i][j]=dp[0][i-1][j];
        for(j=k-a[i];j>=0;j--)
            dp[0][i][j+a[i]]|=dp[0][i][j];
    }
    dp[1][n+1][0]=1;
    for(i=n;i>=1;i--)
    {
        for(j=0;j<=k;j++)
            dp[1][i][j]=dp[1][i+1][j];
        for(j=k-a[i];j>=0;j--)
            dp[1][i][j+a[i]]|=dp[1][i][j];
    }
    for(i=1;i<=n;i++)
    {
        n1=n2=0;
        for(j=0;j<k;j++)
            if(dp[0][i-1][j])
               l[++n1]=j;
        for(j=0;j<k;j++)
            if(dp[1][i+1][j])
               r[++n2]=j;
        if(!check()) ++ans;
    }
    cout<<ans;
    return 0;
}

Submission Info

Submission Time
Task C - Go Home
User Bodo
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1144 Byte
Status RE
Exec Time 183 ms
Memory 195456 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 200
Status
AC × 1
WA × 2
AC × 2
WA × 2
RE × 14
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.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
Case Name Status Exec Time Memory
0_000.txt WA 2 ms 2304 KB
0_001.txt AC 2 ms 2304 KB
0_002.txt WA 2 ms 2304 KB
1_003.txt RE 183 ms 166016 KB
1_004.txt RE 176 ms 195328 KB
1_005.txt AC 2 ms 2304 KB
1_006.txt RE 161 ms 195328 KB
1_007.txt RE 162 ms 195456 KB
1_008.txt RE 161 ms 195328 KB
1_009.txt RE 162 ms 195328 KB
1_010.txt RE 162 ms 195328 KB
1_011.txt RE 161 ms 195328 KB
1_012.txt RE 162 ms 195328 KB
1_013.txt RE 161 ms 195328 KB
1_014.txt RE 160 ms 195328 KB
1_015.txt RE 161 ms 195328 KB
1_016.txt RE 161 ms 195328 KB
1_017.txt RE 161 ms 195328 KB