提出 #23133750


ソースコード 拡げる

import itertools
import sys; sys.setrecursionlimit(10**9)
N,M,Q=map(int,input().split())

D = []
for _ in range(Q):
    *x,=map(int,input().split())
    D.append(x)

ans = 0
def dfs(lst):
    global ans
    if len(lst) == N:
        cum = 0
        for a,b,c,d in D:
            if lst[b-1] - lst[a-1] == c:
                cum += d
        ans = max(ans, cum)
        return
    for ni in range(lst[-1], M+1):
        dfs(lst[:] + [ni])
for m in range(1, M+1):
    dfs([m])
print(ans)

提出情報

提出日時
問題 C - Many Requirements
ユーザ lightning
言語 Python (3.8.2)
得点 300
コード長 508 Byte
結果 AC
実行時間 579 ms
メモリ 9216 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 15
セット名 テストケース
Sample 00-sample-00, 00-sample-01, 00-sample-02
All 00-sample-00, 00-sample-01, 00-sample-02, 01-handmade-03, 01-handmade-04, 01-handmade-05, 01-handmade-06, 02-random-07, 02-random-08, 02-random-09, 02-random-10, 02-random-11, 02-random-12, 02-random-13, 02-random-14
ケース名 結果 実行時間 メモリ
00-sample-00 AC 17 ms 9156 KiB
00-sample-01 AC 19 ms 9028 KiB
00-sample-02 AC 111 ms 9032 KiB
01-handmade-03 AC 18 ms 9216 KiB
01-handmade-04 AC 579 ms 8928 KiB
01-handmade-05 AC 491 ms 9032 KiB
01-handmade-06 AC 17 ms 9088 KiB
02-random-07 AC 19 ms 9148 KiB
02-random-08 AC 18 ms 8928 KiB
02-random-09 AC 20 ms 9208 KiB
02-random-10 AC 21 ms 8924 KiB
02-random-11 AC 20 ms 9152 KiB
02-random-12 AC 24 ms 8924 KiB
02-random-13 AC 70 ms 9216 KiB
02-random-14 AC 550 ms 9212 KiB