Submission #1443204
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long int64; const int mod = 1e9 + 7; int N, C, A[400], B[400]; int64 mat[401][401]; int main() { cin >> N >> C; for(int i = 0; i < N; i++) cin >> A[i]; for(int i = 0; i < N; i++) cin >> B[i]; for(int i = 0; i < N; i++) { for(int k = A[i]; k <= B[i]; k++) { int64 ret = 1; for(int j = 0; j <= C; j++) { (mat[i][j] += ret) %= mod; (ret = ret * k) %= mod; } } } vector< int64 > curr(C + 1, 0); curr[0] = 1; for(int i = 0; i < N; i++) { vector< int64 > next(C + 1, 0); for(int j = 0; j <= C; j++) { for(int k = 0; k <= j; k++) { (next[j] += curr[j - k] * mat[i][k]) %= mod; } } curr.swap(next); } cout << curr[C] << endl; }
Submission Info
Submission Time | |
---|---|
Task | E - Children and Candies |
User | ei13333 |
Language | C++14 (GCC 5.4.1) |
Score | 800 |
Code Size | 828 Byte |
Status | AC |
Exec Time | 453 ms |
Memory | 1536 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 | 1 ms | 256 KB |
1_010.txt | AC | 1 ms | 256 KB |
1_011.txt | AC | 2 ms | 1536 KB |
1_012.txt | AC | 2 ms | 1536 KB |
1_013.txt | AC | 2 ms | 1536 KB |
1_014.txt | AC | 129 ms | 1536 KB |
1_015.txt | AC | 129 ms | 1536 KB |
1_016.txt | AC | 129 ms | 1536 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 | 3 ms | 1536 KB |
2_022.txt | AC | 2 ms | 1536 KB |
2_023.txt | AC | 453 ms | 1536 KB |
2_024.txt | AC | 240 ms | 1536 KB |
2_025.txt | AC | 62 ms | 1536 KB |
2_026.txt | AC | 6 ms | 1280 KB |
2_027.txt | AC | 194 ms | 1408 KB |
2_028.txt | AC | 9 ms | 640 KB |
2_029.txt | AC | 3 ms | 384 KB |