QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#286579#5592. Family Visitsmfshi03Compile Error//C++141.3kb2023-12-18 03:51:322023-12-18 03:51:33

Judging History

你现在查看的是最新测评结果

  • [2023-12-18 03:51:33]
  • 评测
  • [2023-12-18 03:51:32]
  • 提交

answer

import sys
sys.setrecursionlimit(1000000)

n, d = map(int, input().split())

mess = [0 for i in range(n)]
times = [0 for i in range(n)]
prefix = [0 for i in range(n + 1)]
for i in range(n):
    m, c = map(int, input().split())
    mess[i] = m
    prefix[i+1] = prefix[i] + m
    times[i] = c

cache = dict()

def recur(start, i, target, count):
    print(start, i, target, count, prefix[i+1] - prefix[start])
    if target <= 0:
        return count 

    if i < start:
        return float("inf")

    if (i, target) in cache:
        return cache[(i, target)]

    val = float("inf")

    removed = min(times[i], prefix[i+1] - prefix[start])
    if mess[i] == 0:
        val = recur(start, i - 1, target, count)

    cache[(i, target)] = min(recur(start, i - 1, target - removed, count + 1), val)
    return cache[(i, target)]
    

cdays = 0
start = 0
np = False
days = []
for i in range(d):
    days.append(int(input()))
    
for day in days:

    if times[day - 1] < mess[day - 1]:
        np = True
        break

    clean_days = recur(start, day - 1, prefix[day] - prefix[start], 0)
    print(clean_days)
    print()
    if clean_days == float("inf"):
        np = True
        break

    cdays += clean_days
    start = day

if np:
    print(-1)
else:
    print(cdays)




Details

answer.code:1:1: error: ‘import’ does not name a type
    1 | import sys
      | ^~~~~~
answer.code:1:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’