Submission #3229959


Source Code Expand

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 5010

bool dp[MAX_N][MAX_N] = {};
bool maked[MAX_N][MAX_N] = {};     // グループ内の数の組み合わせで i 抜きで j が作れるなら true
int N, K;
int A[MAX_N];

// 今 i を見ていて、現在の数が j のとき
// ただし A[skip] は加算せずにとばす
void dfs(int i, int j, int skip) {
    if(i >= N) { return; }
    if(dp[i][j]) { return; }
    dfs(i+1, j, skip);
    if(i != skip && j + A[i] < K) {
        maked[skip][j + A[i]] = true;
        dfs(i+1, j + A[i], skip);
    }
    dp[i][j] = true;
}

signed main()
{
    cin >> N >> K;
    REP(i, N) { cin >> A[i]; }
    REP(i, N) {
        ZERO(dp);
        dfs(0, 0, i);
    }
    ll ans = N;
    REP(i, N) {
        for(int j = K - A[i]; j < K; ++j) {
            if( j <= 0 || maked[i][j]) {
                ans--;
                break;
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Submission Info

Submission Time
Task D - No Need
User VTR
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1466 Byte
Status TLE
Exec Time 2104 ms
Memory 28544 KB

Judge Result

Set Name Sample Subtask All
Score / Max Score 0 / 0 300 / 300 0 / 300
Status
AC × 3
AC × 26
AC × 32
TLE × 19
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 12 ms 26752 KB
0_001.txt AC 16 ms 26752 KB
0_002.txt AC 17 ms 26752 KB
1_003.txt AC 8 ms 26752 KB
1_004.txt AC 8 ms 26752 KB
1_005.txt AC 8 ms 26752 KB
1_006.txt AC 33 ms 26880 KB
1_007.txt AC 34 ms 26880 KB
1_008.txt AC 1049 ms 28544 KB
1_009.txt AC 1001 ms 28544 KB
1_010.txt AC 766 ms 26752 KB
1_011.txt AC 776 ms 26752 KB
1_012.txt AC 767 ms 26752 KB
1_013.txt AC 768 ms 26752 KB
1_014.txt AC 775 ms 26752 KB
1_015.txt AC 1447 ms 28544 KB
1_016.txt AC 21 ms 26880 KB
1_017.txt AC 25 ms 26880 KB
1_018.txt AC 24 ms 26880 KB
1_019.txt AC 792 ms 28544 KB
1_020.txt AC 776 ms 28416 KB
1_021.txt AC 1079 ms 28416 KB
1_022.txt AC 422 ms 27520 KB
1_023.txt AC 263 ms 27392 KB
1_024.txt AC 932 ms 28416 KB
1_025.txt AC 976 ms 28544 KB
2_026.txt AC 8 ms 26752 KB
2_027.txt AC 42 ms 26880 KB
2_028.txt AC 42 ms 26880 KB
2_029.txt TLE 2103 ms 27136 KB
2_030.txt TLE 2104 ms 27136 KB
2_031.txt TLE 2104 ms 27008 KB
2_032.txt TLE 2104 ms 27008 KB
2_033.txt TLE 2104 ms 27008 KB
2_034.txt TLE 2104 ms 27008 KB
2_035.txt TLE 2104 ms 27008 KB
2_036.txt TLE 2104 ms 27136 KB
2_037.txt AC 29 ms 26880 KB
2_038.txt AC 31 ms 26880 KB
2_039.txt AC 31 ms 26880 KB
2_040.txt TLE 2104 ms 27392 KB
2_041.txt TLE 2103 ms 27136 KB
2_042.txt TLE 2103 ms 27136 KB
2_043.txt TLE 2103 ms 27008 KB
2_044.txt TLE 2103 ms 27136 KB
2_045.txt TLE 2103 ms 27136 KB
2_046.txt TLE 2103 ms 27136 KB
2_047.txt TLE 2104 ms 27136 KB
2_048.txt TLE 2103 ms 27136 KB
2_049.txt TLE 2103 ms 27136 KB
2_050.txt TLE 2104 ms 27136 KB