This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e2+2, mod = 1e9+7;
int n, a[N], b[N], f[N], dp[2][N];
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
f[1] = 1;
f[2] = 2;
for (int i = 3; i < N; i++) {
f[i] = (f[i-1] + f[i-2]) % mod;
}
for (int i = 0; i < n; i++) {
b[i] = a[i];
sort(b, b+i+1);
for (int j = 0; j <= i; j++) {
dp[0][j] = dp[1][j] = 0;
// puedo coger desde b[j]
int sz = b[j] - (j ? b[j-1] : 0) - 1;
dp[0][j] += (1 + sz/2) * (j ? dp[0][j-1] : 1) % mod;
dp[0][j] %= mod;
if (j) {
sz++;
dp[0][j] += (1 + sz/2) * dp[1][j-1] % mod;
dp[0][j] %= mod;
}
// puedo coger desde b[j]-1
sz = b[j] - (j ? b[j-1] : 0) - 1;
dp[1][j] += (sz/2) * (j ? dp[0][j-1] : 1) % mod;
dp[1][j] %= mod;
if (j) {
sz++;
dp[1][j] += (sz/2) * dp[1][j-1] % mod;
dp[1][j] %= mod;
}
}
cout << dp[0][i] << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |