Dynamic programing(tabulation) - problem from cses problem set COINS COMBINATION(ll) https://cses.fi/problemset/result/5845525/ why my solutin giving tle

#include <bits/stdc++.h>
using namespace std;
const int m =1e9+7;
int N=1e6+1;

vector<vector> dp(N, vector(101, 0));

int main() {
int n, x;
cin >> n >> x;
vector arr(n);
for(auto &it:arr) cin>>it;

for(int i=0;i<n;++i) dp[0][i]=1;
for(int sum = 1; sum<=x; ++sum) {
int count=0;
for(int i=0; i<n; ++i) {
if(sum-arr[i] >= 0) count+=(dp[sum-arr[i]][i]);
count %= m;
dp[sum][i] = count;
}

}
cout<<dp[x][n-1];

return 0;

}

The code doesn’t compile. Also, it would help to write it in such a way that it uses only O(x) memory (as opposed to O(nx)).