Submission #16867108


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 = 998_244_353

@njit((i8, i8[:]), cache=True)
def main(N, LR):
    L, R = LR[::2], LR[1::2]
    K = len(L)
    F = np.zeros(N + 10, np.int64)
    F[0] = 1
    for n in range(1, N + 10):
        F[n] += F[n - 1]
        for k in range(K):
            l, r = L[k], R[k] + 1
            if n - l >= 0:
                F[n] += F[n - l]
            if n - r >= 0:
                F[n] -= F[n - r]
        F[n] %= MOD
    ans = F[N - 1] - F[N - 2]
    return ans % MOD

N, K = map(int, readline().split())
LR = np.array(read().split(), np.int64)

print(main(N, LR))

Submission Info

Submission Time
Task D - Leaping Tak
User maspy
Language Python (3.8.2)
Score 400
Code Size 784 Byte
Status
Exec Time 517 ms
Memory 107908 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
× 4
× 28
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt, s4.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, s1.txt, s2.txt, s3.txt, s4.txt
Case Name Status Exec Time Memory
01.txt 510 ms 106344 KB
02.txt 499 ms 105784 KB
03.txt 488 ms 105912 KB
04.txt 497 ms 105704 KB
05.txt 496 ms 105728 KB
06.txt 508 ms 106428 KB
07.txt 513 ms 105976 KB
08.txt 507 ms 105884 KB
09.txt 508 ms 105756 KB
10.txt 505 ms 106408 KB
11.txt 504 ms 105728 KB
12.txt 510 ms 106972 KB
13.txt 498 ms 107220 KB
14.txt 517 ms 106464 KB
15.txt 496 ms 107632 KB
16.txt 503 ms 107120 KB
17.txt 490 ms 107888 KB
18.txt 507 ms 107368 KB
19.txt 500 ms 106992 KB
20.txt 497 ms 107164 KB
21.txt 499 ms 106988 KB
22.txt 501 ms 107248 KB
23.txt 504 ms 107908 KB
24.txt 499 ms 107000 KB
s1.txt 496 ms 106428 KB
s2.txt 499 ms 105724 KB
s3.txt 498 ms 105732 KB
s4.txt 505 ms 106344 KB