Submission #837500


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

const LL mod = 1e9+7;

const int maxn = 400+10;

LL fac[maxn][maxn];
LL facsum[maxn][maxn];


int A[maxn],B[maxn];
int n,C;

LL dp[maxn][maxn];

int main()
{
 //  freopen("./test.txt","r",stdin);
    for(int i = 1;i < maxn;++i)
        fac[0][i] = 1;
    for(int i = 1;i < maxn;++i)
        for(int j = 1;j < maxn;++j)
            fac[i][j] = fac[i-1][j]*j%mod;

    for(int i = 0;i < maxn;++i)
    {
        facsum[i][0] = 0;
        for(int j = 1;j < maxn;++j)
            facsum[i][j] = (facsum[i][j-1] + fac[i][j])%mod;
    }

    scanf("%d %d",&n,&C);
    for(int i = 1;i <= n;++i)
        scanf("%d",&A[i]);
    for(int i = 1;i <= n;++i)
        scanf("%d",&B[i]);
    memset(dp,0,sizeof(dp));

    dp[0][C] = 1;
    for(int i = 0;i < n;++i)
        for(int j = C;j >= 0;--j)
        {
            if(dp[i][j] == 0) continue;
            for(int giv = j;giv >= 0;--giv)
            {

                int lft = j-giv;
                int L = A[i+1],R = B[i+1];

                LL t = (facsum[giv][R]-facsum[giv][L-1]+mod)%mod;
                t = t*dp[i][j]%mod;
                dp[i+1][lft] = (dp[i+1][lft] + t)%mod;

            }
        }


    LL res = dp[n][0];
    printf("%lld\n",res);
    return 0;

}

Submission Info

Submission Time
Task E - Children and Candies
User wumpus
Language C++14 (GCC 5.4.1)
Score 800
Code Size 1352 Byte
Status AC
Exec Time 634 ms
Memory 4224 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:35:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&C);
                         ^
./Main.cpp:37:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&A[i]);
                          ^
./Main.cpp:39:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&B[i]);
                          ^

Judge Result

Set Name Sample Subtask All
Score / Max Score 0 / 0 400 / 400 400 / 400
Status
AC × 5
AC × 12
AC × 30
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 11 ms 4224 KB
0_001.txt AC 11 ms 4224 KB
0_002.txt AC 12 ms 4224 KB
0_003.txt AC 12 ms 4224 KB
0_004.txt AC 11 ms 4224 KB
1_005.txt AC 11 ms 4224 KB
1_006.txt AC 12 ms 4224 KB
1_007.txt AC 11 ms 4224 KB
1_008.txt AC 12 ms 4224 KB
1_009.txt AC 12 ms 4224 KB
1_010.txt AC 12 ms 4224 KB
1_011.txt AC 12 ms 4224 KB
1_012.txt AC 13 ms 4224 KB
1_013.txt AC 12 ms 4224 KB
1_014.txt AC 541 ms 4224 KB
1_015.txt AC 554 ms 4224 KB
1_016.txt AC 545 ms 4224 KB
2_017.txt AC 12 ms 4224 KB
2_018.txt AC 11 ms 4224 KB
2_019.txt AC 12 ms 4224 KB
2_020.txt AC 12 ms 4224 KB
2_021.txt AC 11 ms 4224 KB
2_022.txt AC 12 ms 4224 KB
2_023.txt AC 634 ms 4224 KB
2_024.txt AC 587 ms 4224 KB
2_025.txt AC 92 ms 4224 KB
2_026.txt AC 12 ms 4224 KB
2_027.txt AC 463 ms 4224 KB
2_028.txt AC 18 ms 4224 KB
2_029.txt AC 13 ms 4224 KB