Submission #24964

# Submission time Handle Problem Language Result Execution time Memory
24964 2017-06-19T01:03:19 Z leejseo None (KOI16_resort) PyPy
0 / 100
2 ms 0 KB
from sys import maxint
def solve(n, L):
    D = [ [maxint]*(2*i + 1) for i in range(n+1)]
    D[0][0] = 0
    for i in range (n):
        for j in range(2*i +1):
            if i+1 in L:
                D[i+1][j] = D[i][j]
                continue
            D[i+1][j] = min(D[i+1][j], D[i][j]+10000)
            for k in range(1, 4):
                if i + k > n: break
                D[i+k][j+1] = min(D[i+k][j+1], D[i][j]+25000)
            for k in range(1, 6):
                if i + k > n: break
                D[i+k][j+2] = min(D[i+k][j+2], D[i][j]+37000)
            if j >= 3:
                D[i+1][j-3] = min(D[i+1][j-3], D[i][j])
    return min(D[n])

def main():
    n, k = map(int, raw_input().split())
    L = map(int, raw_input().split())
    print solve(n, L)
    return
main()
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 0 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 0 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 0 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -