Submission #18578079


Source Code Expand

Copy
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 1_000_000_007

def from_read(dtype=np.int64):
    return np.fromstring(read().decode(), dtype=dtype, sep=' ')


def from_readline(dtype=np.int64):
    return np.fromstring(readline().decode(), dtype=dtype, sep=' ')

@njit
def mpow(a, n):
    p = 1
    while n:
        if n & 1:
            p = p * a % MOD
        a = a * a % MOD
        n >>= 1
    return p

@njit((i8, i8, i8[:]), cache=True)
def main(N, M, A):
    N, K = M + N, A.sum() + N
    # Kis small
    if not 0 <= K <= N:
        return 0
    num, den = 1, 1
    for i in range(K):
        num = num * (N - i) % MOD
        den = den * (i + 1) % MOD
    return num * mpow(den, MOD - 2) % MOD

N, M = from_readline()
A = from_read()

print(main(N, M, A))

Submission Info

Submission Time
Task D - Binomial Coefficient is Fun
User maspy
Language Python (3.8.2)
Score 600
Code Size 954 Byte
Status AC
Exec Time 568 ms
Memory 106628 KB

Judge Result

Set Name All Sample
Score / Max Score 600 / 600 0 / 0
Status
AC × 72
AC × 2
Set Name Test Cases
All sample_01.txt, sample_02.txt, testcase_1.txt, testcase_10.txt, testcase_11.txt, testcase_12.txt, testcase_13.txt, testcase_14.txt, testcase_15.txt, testcase_16.txt, testcase_17.txt, testcase_18.txt, testcase_19.txt, testcase_2.txt, testcase_20.txt, testcase_21.txt, testcase_22.txt, testcase_23.txt, testcase_24.txt, testcase_25.txt, testcase_26.txt, testcase_27.txt, testcase_28.txt, testcase_29.txt, testcase_3.txt, testcase_30.txt, testcase_31.txt, testcase_32.txt, testcase_33.txt, testcase_34.txt, testcase_35.txt, testcase_36.txt, testcase_37.txt, testcase_38.txt, testcase_39.txt, testcase_4.txt, testcase_40.txt, testcase_41.txt, testcase_42.txt, testcase_43.txt, testcase_44.txt, testcase_45.txt, testcase_46.txt, testcase_47.txt, testcase_48.txt, testcase_49.txt, testcase_5.txt, testcase_50.txt, testcase_51.txt, testcase_52.txt, testcase_53.txt, testcase_54.txt, testcase_55.txt, testcase_56.txt, testcase_57.txt, testcase_58.txt, testcase_59.txt, testcase_6.txt, testcase_60.txt, testcase_61.txt, testcase_62.txt, testcase_63.txt, testcase_64.txt, testcase_65.txt, testcase_66.txt, testcase_67.txt, testcase_68.txt, testcase_69.txt, testcase_7.txt, testcase_70.txt, testcase_8.txt, testcase_9.txt
Sample sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
sample_01.txt AC 538 ms 106416 KB
sample_02.txt AC 519 ms 105788 KB
testcase_1.txt AC 544 ms 105768 KB
testcase_10.txt AC 523 ms 105272 KB
testcase_11.txt AC 540 ms 105780 KB
testcase_12.txt AC 543 ms 105752 KB
testcase_13.txt AC 530 ms 105988 KB
testcase_14.txt AC 537 ms 105684 KB
testcase_15.txt AC 532 ms 106500 KB
testcase_16.txt AC 527 ms 105808 KB
testcase_17.txt AC 533 ms 105672 KB
testcase_18.txt AC 531 ms 105744 KB
testcase_19.txt AC 536 ms 105996 KB
testcase_2.txt AC 528 ms 105244 KB
testcase_20.txt AC 534 ms 105808 KB
testcase_21.txt AC 536 ms 106404 KB
testcase_22.txt AC 531 ms 105748 KB
testcase_23.txt AC 531 ms 105668 KB
testcase_24.txt AC 555 ms 106024 KB
testcase_25.txt AC 533 ms 105680 KB
testcase_26.txt AC 535 ms 105764 KB
testcase_27.txt AC 537 ms 105764 KB
testcase_28.txt AC 536 ms 105984 KB
testcase_29.txt AC 532 ms 105328 KB
testcase_3.txt AC 522 ms 106052 KB
testcase_30.txt AC 535 ms 105768 KB
testcase_31.txt AC 534 ms 105836 KB
testcase_32.txt AC 535 ms 106444 KB
testcase_33.txt AC 530 ms 105784 KB
testcase_34.txt AC 535 ms 105808 KB
testcase_35.txt AC 530 ms 106588 KB
testcase_36.txt AC 534 ms 105800 KB
testcase_37.txt AC 539 ms 106584 KB
testcase_38.txt AC 535 ms 105752 KB
testcase_39.txt AC 553 ms 105780 KB
testcase_4.txt AC 520 ms 106048 KB
testcase_40.txt AC 538 ms 106016 KB
testcase_41.txt AC 531 ms 106448 KB
testcase_42.txt AC 536 ms 105776 KB
testcase_43.txt AC 529 ms 105256 KB
testcase_44.txt AC 537 ms 105248 KB
testcase_45.txt AC 535 ms 106516 KB
testcase_46.txt AC 531 ms 105804 KB
testcase_47.txt AC 533 ms 106428 KB
testcase_48.txt AC 531 ms 105740 KB
testcase_49.txt AC 534 ms 106440 KB
testcase_5.txt AC 521 ms 105356 KB
testcase_50.txt AC 536 ms 106592 KB
testcase_51.txt AC 533 ms 105788 KB
testcase_52.txt AC 532 ms 106628 KB
testcase_53.txt AC 560 ms 105748 KB
testcase_54.txt AC 524 ms 106496 KB
testcase_55.txt AC 524 ms 105764 KB
testcase_56.txt AC 527 ms 106512 KB
testcase_57.txt AC 522 ms 105352 KB
testcase_58.txt AC 521 ms 105784 KB
testcase_59.txt AC 520 ms 106500 KB
testcase_6.txt AC 520 ms 105252 KB
testcase_60.txt AC 520 ms 106044 KB
testcase_61.txt AC 521 ms 105684 KB
testcase_62.txt AC 526 ms 105296 KB
testcase_63.txt AC 520 ms 105784 KB
testcase_64.txt AC 532 ms 105752 KB
testcase_65.txt AC 533 ms 106424 KB
testcase_66.txt AC 562 ms 105364 KB
testcase_67.txt AC 568 ms 105832 KB
testcase_68.txt AC 564 ms 105860 KB
testcase_69.txt AC 560 ms 106000 KB
testcase_7.txt AC 553 ms 105616 KB
testcase_70.txt AC 530 ms 106508 KB
testcase_8.txt AC 547 ms 105772 KB
testcase_9.txt AC 560 ms 105784 KB