Skip to content

Instantly share code, notes, and snippets.

@jamak
Created March 30, 2015 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamak/d70d6394f50289b6bef1 to your computer and use it in GitHub Desktop.
Save jamak/d70d6394f50289b6bef1 to your computer and use it in GitHub Desktop.
def res(n):
dp = [0] * (n+1)
for t in xrange(n):
dp[t+1] = max(dp[t+1], dp[t]+1) # press a
for k in xrange(t+3, min(t+7, n+1)):
dp[k] = max(dp[k], dp[t]*(k-t-1)) # press select all, copy, paste x (k-t-1)
return dp[n]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment