#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;
}
*/
//int sum = 0;
//int SZ = 0;
for (int i = 0; i < n; i++) {
//sum += f[a[i]];
//SZ++;
b[i] = a[i];
sort(b, b+i+1);
/**
if (i >= 1 && b[1] == 1) {
b[0] = 2;
for (int j = 1; j+1 <= i; j++) {
b[j] = b[j+1];
}
SZ--;
}
*/
for (int j = 0; j <= i/*SZ*/; 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/*SZ-1*/] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
207 ms |
592 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |