Language: C++

#include <iostream>
using namespace std;
#define F first
#define S second
#define ios ios_base::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
ll x;
vector<int>tmp[6005];
vector<int>shel_dplft[6005];
vector<int>shel_dprt[6005];
int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll>a(n + 1);
    for(int i  = 1; i <= n; i++)
        cin >> a[i];
    vector<int>dp(5001, 0);
    dp[0] = 1;
    for(int i = 1; i <= n; i++){
        vector<int>lol;
        for(int j = 5000 - a[i]; j>=0; j--)
            dp[j + a[i]] += dp[j];
        for(int j = 0; j <= 5000; j++)
            if(dp[j])
                lol.push_back(j);
        shel_dplft[i] = lol;
    }
    dp.clear();
    dp.assign(5001, 0);
    dp[0] = 1;
    for(int i = n; i >= 1; i--){
        vector<int>lol;
        for(int j = 5000 - a[i]; j>=0; j--)
            dp[j + a[i]] += dp[j];
        for(int j = 0; j <= 5000; j++)
            if(dp[j])
                lol.push_back(j);
        shel_dprt[i] = lol;
    }
    shel_dplft[0].push_back(0);
    shel_dprt[n + 1].push_back(0);
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        vector<int>red = shel_dplft[i-1];
        vector<int>blue = shel_dprt[i + 1];
        for(auto v : red){
            int lo = 0, hi = blue.size() - 1;
            while(lo < hi){
                int md =lo + (hi - lo + 1)/2;
                if(v + blue[md] < k)
                    lo = md;
                else
                    hi = md - 1;
            }
            if(v + blue[lo] + a[i] >= k && v + blue[lo] < k){
                cnt++;
                break;
            }
        }
    }
    cout << n - cnt << '\n';
    return 0;
}


Compiler output:
a.cc:8:9: error: 'vector' does not name a type
    8 | typedef vector<int> vi;
      |         ^~~~~~
a.cc:10:1: error: 'vector' does not name a type
   10 | vector<int>tmp[6005];
      | ^~~~~~
a.cc:11:1: error: 'vector' does not name a type
   11 | vector<int>shel_dplft[6005];
      | ^~~~~~
a.cc:12:1: error: 'vector' does not name a type
   12 | vector<int>shel_dprt[6005];
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:16:5: error: 'vector' was not declared in this scope
   16 |     vector<ll>a(n + 1);
      |     ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:16:14: error: expected primary-expression before '>' token
   16 |     vector<ll>a(n + 1);
      |              ^
a.cc:16:15: error: 'a' was not declared in this scope
   16 |     vector<ll>a(n + 1);
      |               ^
a.cc:19:12: error: expected primary-expression before 'int'
   19 |     vector<int>dp(5001, 0);
      |            ^~~
a.cc:20:5: error: 'dp' was not declared in this scope
   20 |     dp[0] = 1;
      |     ^~
a.cc:22:16: error: expected primary-expression before 'int'
   22 |         vector<int>lol;
      |                ^~~
a.cc:27:17: error: 'lol' was not declared in this scope; did you mean 'll'?
   27 |                 lol.push_back(j);
      |                 ^~~
      |                 ll
a.cc:28:9: error: 'shel_dplft' was not declared in this scope
   28 |         shel_dplft[i] = lol;
      |         ^~~~~~~~~~
a.cc:28:25: error: 'lol' was not declared in this scope; did you mean 'll'?
   28 |         shel_dplft[i] = lol;
      |                         ^~~
      |                         ll
a.cc:34:16: error: expected primary-expression before 'int'
   34 |         vector<int>lol;
      |                ^~~
a.cc:39:17: error: 'lol' was not declared in this scope; did you mean 'll'?
   39 |                 lol.push_back(j);
      |                 ^~~
      |                 ll
a.cc:40:9: error: 'shel_dprt' was not declared in this scope
   40 |         shel_dprt[i] = lol;
      |         ^~~~~~~~~
a.cc:40:24: error: 'lol' was not declared in this scope; did you mean 'll'?
   40 |         shel_dprt[i] = lol;
      |                        ^~~
      |                        ll
a.cc:42:5: error: 'shel_dplft' was not declared in this scope
   42 |     shel_dplft[0].push_back(0);
      |     ^~~~~~~~~~
a.cc:43:5: error: 'shel_dprt' was not declared in this scope
   43 |     shel_dprt[n + 1].push_back(0);
      |     ^~~~~~~~~
a.cc:46:16: error: expected primary-expression before 'int'
   46 |         vector<int>red = shel_dplft[i-1];
      |                ^~~
a.cc:47:16: error: expected primary-expression before 'int'
   47 |         vector<int>blue = shel_dprt[i + 1];
      |                ^~~
a.cc:48:22: error: 'red' was not declared in this scope
   48 |         for(auto v : red){
      |                      ^~~
a.cc:49:30: error: 'blue' was not declared in this scope
   49 |             int lo = 0, hi = blue.size() - 1;
      |                              ^~~~