#include<bits/stdc++.h>
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
const int maxn = 1e4+1, mod = 1e6 + 7;
using state = array<int, maxn>;
int n;
state def;
void add(int &a, int b) { a = a+b>=mod?a+b-mod:a+b; }
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
def.fill(0);
state dp = def;
int lk = 0;
for(int A, i = 1; i <= n; i++) {
cin >> A;
add(ndp[lk], A-1);
lk = max(lk, A);
auto ndp = def;
for(int k = 0; k < i; k++) {
ndp[k] = (ndp[k] + dp[k]*1ll*k)%mod;
add(ndp[k+1], dp[k]);
}
dp = ndp;
//for(int i = 0; i <= n; i++) cout << dp[i] << " "; cout << endl;
}
int sm = 0;
for(int i = 0; i <= n; i++) add(sm, dp[i]);
cout << sm << '\n';
}
Compilation message
teams.cpp: In function 'int main()':
teams.cpp:18:7: error: 'ndp' was not declared in this scope; did you mean 'dp'?
18 | add(ndp[lk], A-1);
| ^~~
| dp