Submission #4805024
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;
#define M 900
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int t;
cin >> t;
vector<int> a(M);
reps(i, t){
cin >> a[i];
}
int dp[M][M];
memset(dp, 0, sizeof(dp));
rep(j, a[1] + 1){
dp[1][j] = 1;
}
reps(i, t){
dp[i][1] = min(1, a[i]);
}
REP(i, 2, M){
for(int j = 0 ; j < M ; j += 2){
rep(k, a[i] + 1){
if((j / 2 + k) % 2 == 0 || (j == 2 && k == 0)){
dp[i][j / 2 + k] += dp[i - 1][j];
dp[i][j / 2 + k] %= MOD;
}
}
}
}
int ans = 0;
rep(i, M){
ans += dp[i][1];
ans %= MOD;
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Union |
User |
mhrb |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
1657 Byte |
Status |
AC |
Exec Time |
66 ms |
Memory |
3456 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
400 / 400 |
Status |
|
|
Set Name |
Test Cases |
Sample |
s1.txt, s2.txt, s3.txt |
All |
01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, s1.txt, s2.txt, s3.txt |
Case Name |
Status |
Exec Time |
Memory |
01.txt |
AC |
3 ms |
3456 KB |
02.txt |
AC |
3 ms |
3456 KB |
03.txt |
AC |
3 ms |
3456 KB |
04.txt |
AC |
3 ms |
3456 KB |
05.txt |
AC |
3 ms |
3456 KB |
06.txt |
AC |
7 ms |
3456 KB |
07.txt |
AC |
7 ms |
3456 KB |
08.txt |
AC |
7 ms |
3456 KB |
09.txt |
AC |
7 ms |
3456 KB |
10.txt |
AC |
7 ms |
3456 KB |
11.txt |
AC |
34 ms |
3456 KB |
12.txt |
AC |
36 ms |
3456 KB |
13.txt |
AC |
34 ms |
3456 KB |
14.txt |
AC |
34 ms |
3456 KB |
15.txt |
AC |
35 ms |
3456 KB |
16.txt |
AC |
64 ms |
3456 KB |
17.txt |
AC |
64 ms |
3456 KB |
18.txt |
AC |
65 ms |
3456 KB |
19.txt |
AC |
63 ms |
3456 KB |
20.txt |
AC |
65 ms |
3456 KB |
21.txt |
AC |
66 ms |
3456 KB |
22.txt |
AC |
64 ms |
3456 KB |
23.txt |
AC |
66 ms |
3456 KB |
24.txt |
AC |
65 ms |
3456 KB |
25.txt |
AC |
65 ms |
3456 KB |
26.txt |
AC |
65 ms |
3456 KB |
27.txt |
AC |
4 ms |
3456 KB |
28.txt |
AC |
4 ms |
3456 KB |
29.txt |
AC |
4 ms |
3456 KB |
30.txt |
AC |
3 ms |
3456 KB |
s1.txt |
AC |
3 ms |
3456 KB |
s2.txt |
AC |
3 ms |
3456 KB |
s3.txt |
AC |
5 ms |
3456 KB |