Runtime error in question "boredom" (455A)

Правка en1, от vasanthaganesh, 2016-01-20 16:10:42

link to the question: http://codeforces.net/contest/455/problem/A

Source-code:

from collections import Counter import sys sys.setrecursionlimit(100000000)

raw_input() a = map(int, raw_input().split())

f = Counter(a)

memo = {} def dp(i): if i in memo: return memo[i] elif i <= 0: temp = 0 else: if i not in f: temp = max(dp(i-1), dp(i-2)) else: temp = i*f[i] + max(dp(i-2), dp(i-3)) memo[i] = temp return temp

print max(dp(max(a)), dp(max(a) — 1))

Теги dynamic programming, runtime error

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский vasanthaganesh 2016-01-20 17:42:55 216 updated blog text
en2 Английский vasanthaganesh 2016-01-20 16:32:56 424 code was not displayed properly, so i linked the submission
en1 Английский vasanthaganesh 2016-01-20 16:10:42 546 Initial revision (published)