-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
39 lines (33 loc) · 758 Bytes
/
Copy pathmain.cpp
File metadata and controls
39 lines (33 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
constexpr int mod = 1'000'000'007;
constexpr int add(int a, int b) {
return a + b < mod ? a + b : a + b - mod;
}
constexpr int mul(int a, int b) {
return i64(a) * b % mod;
}
auto sol = [](int n, auto v) {
int ret = 0;
vector dp(11, 0);
dp[0] = 1;
for (int i = 0; i < n; i++) {
ret = mul(ret, 2);
auto ndp = dp;
for (int x = 0; x <= 10; x++) {
int nx = max(v[i] - x, 0);
ret = add(ret, mul(dp[x], nx));
ndp[nx] = add(ndp[nx], dp[x]);
}
dp.swap(ndp);
}
return ret;
};
int main() {
cin.tie(0)->sync_with_stdio(0);
int n; cin >> n;
vector v(n, 0);
for (int i = 0; i < n; i++) cin >> v[i];
cout << sol(n, v) << '\n';
}