Submission #1229165
Source Code Expand
// In the name of Allah // #Isart #include<bits/stdc++.h> #define pii pair<int, int> #define pb push_back #define F first #define S second #define ll long long #define ld long double using namespace std; const int MAXN = 400 + 10, mod = 1e9 + 7; ll dp[MAXN][MAXN], sum[MAXN][MAXN]; int a[MAXN], b[MAXN]; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, c; cin >> n >> c; for(int i = 0; i < n; i ++) cin >> a[i]; for(int i = 0; i < n; i ++) cin >> b[i]; dp[0][0] = 1; for(int i = 1; i <= n; i ++){ for(int j = a[i - 1]; j <= b[i - 1]; j ++){ ll tmp = 1; for(int t = 0; t <= c; t ++){ sum[i][t] = (sum[i][t] + tmp) % mod; tmp = 1ll * tmp * j % mod; } } } for(int i = 1; i <= n; i ++){ for(int j = 0; j <= c; j ++){ for(int t = 0; t <= j; t ++){ dp[i][j] = (dp[i][j] + dp[i - 1][j - t] * sum[i][t] % mod) % mod; } } } cout << dp[n][c] << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Children and Candies |
User | MODSART |
Language | C++14 (GCC 5.4.1) |
Score | 800 |
Code Size | 958 Byte |
Status | AC |
Exec Time | 464 ms |
Memory | 2816 KB |
Judge Result
Set Name | Sample | Subtask | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | 400 / 400 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt |
Subtask | 0_001, 0_003, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 2_017.txt, 2_018.txt, 2_019.txt, 2_020.txt, 2_021.txt, 2_022.txt, 2_023.txt, 2_024.txt, 2_025.txt, 2_026.txt, 2_027.txt, 2_028.txt, 2_029.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 1 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
0_002.txt | AC | 1 ms | 256 KB |
0_003.txt | AC | 1 ms | 256 KB |
0_004.txt | AC | 1 ms | 256 KB |
1_005.txt | AC | 1 ms | 256 KB |
1_006.txt | AC | 1 ms | 256 KB |
1_007.txt | AC | 1 ms | 256 KB |
1_008.txt | AC | 1 ms | 256 KB |
1_009.txt | AC | 2 ms | 256 KB |
1_010.txt | AC | 2 ms | 256 KB |
1_011.txt | AC | 3 ms | 2816 KB |
1_012.txt | AC | 3 ms | 2816 KB |
1_013.txt | AC | 3 ms | 2816 KB |
1_014.txt | AC | 140 ms | 2816 KB |
1_015.txt | AC | 140 ms | 2816 KB |
1_016.txt | AC | 140 ms | 2816 KB |
2_017.txt | AC | 1 ms | 256 KB |
2_018.txt | AC | 1 ms | 256 KB |
2_019.txt | AC | 2 ms | 256 KB |
2_020.txt | AC | 2 ms | 256 KB |
2_021.txt | AC | 4 ms | 2816 KB |
2_022.txt | AC | 3 ms | 2816 KB |
2_023.txt | AC | 464 ms | 2816 KB |
2_024.txt | AC | 251 ms | 2816 KB |
2_025.txt | AC | 65 ms | 2816 KB |
2_026.txt | AC | 7 ms | 2304 KB |
2_027.txt | AC | 203 ms | 2560 KB |
2_028.txt | AC | 10 ms | 1024 KB |
2_029.txt | AC | 4 ms | 512 KB |