제출 #24965

#제출 시각아이디문제언어결과실행 시간메모리
24965leejseo리조트 (KOI16_resort)Cpython 2
0 / 100
15 ms2 KiB
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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...