CODE THANKS FESTIVAL 2018(Parallel)

Submission #11183266

Source codeソースコード

import sys
input = sys.stdin.readline

n = int(input())
a = [0] + list(map(int, input().split())) + [0]*100

dp = [[-1]*610 for _ in range(320)]
mod = 10**9 + 7


def solve(i, x):
    if dp[i][x] > -1:
        return dp[i][x]

    dp[i][x] = (1 if x == 1 or x == 0 and a[i] > 0 else 0)
    st = 2 if x == 0 else x & 1
    for j in range(st, a[i]+1, 2):
        dp[i][x] += solve(i+1, (x+j)//2)

    dp[i][x] %= mod
    return dp[i][x]


ans = sum(solve(i, 0) for i in range(1, n+1)) % mod
print(ans)

Submission

Task問題 E - Union
User nameユーザ名 testes89
Created time投稿日時
Language言語 PyPy3 (2.4.0)
Status状態 AC
Score得点 400
Source lengthソースコード長 525 Byte
File nameファイル名
Exec time実行時間 571 ms
Memory usageメモリ使用量 44396 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - s1.txt,s2.txt,s3.txt
All 400 / 400 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,25.txt,26.txt,27.txt,28.txt,29.txt,30.txt,s1.txt,s2.txt,s3.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01.txt AC 168 ms 38256 KB
02.txt AC 168 ms 38256 KB
03.txt AC 166 ms 38256 KB
04.txt AC 168 ms 38256 KB
05.txt AC 167 ms 38256 KB
06.txt AC 201 ms 42736 KB
07.txt AC 197 ms 43884 KB
08.txt AC 200 ms 43612 KB
09.txt AC 196 ms 43484 KB
10.txt AC 202 ms 43484 KB
11.txt AC 274 ms 43996 KB
12.txt AC 302 ms 44124 KB
13.txt AC 272 ms 43868 KB
14.txt AC 268 ms 43996 KB
15.txt AC 269 ms 43996 KB
16.txt AC 571 ms 43356 KB
17.txt AC 465 ms 44252 KB
18.txt AC 467 ms 44124 KB
19.txt AC 460 ms 43884 KB
20.txt AC 484 ms 44124 KB
21.txt AC 470 ms 43868 KB
22.txt AC 464 ms 44124 KB
23.txt AC 465 ms 43868 KB
24.txt AC 467 ms 44396 KB
25.txt AC 489 ms 44200 KB
26.txt AC 467 ms 43868 KB
27.txt AC 163 ms 38256 KB
28.txt AC 168 ms 38256 KB
29.txt AC 165 ms 38256 KB
30.txt AC 165 ms 38256 KB
s1.txt AC 170 ms 38256 KB
s2.txt AC 163 ms 38256 KB
s3.txt AC 198 ms 43372 KB