| 提出番号 | 2331 |
|---|---|
| 提出者 | efunyo |
| 言語 | Python3 |
| 提出日時 | 2020-03-24 21:49:45 |
| 問題名 | (70)アルゴリズムのお勉強 |
| 結果 | WA |
| 点数 | 0% |
| テストケース | 結果 | 得点 | 実行時間 | メモリ使用量 |
|---|---|---|---|---|
| 1 | WA | 0% | 26ms | 34400KB |
| 2 | WA | 0% | 26ms | 34800KB |
| 3 | WA | 0% | 26ms | 35152KB |
| 4 | WA | 0% | 26ms | 35072KB |
| 5 | WA | 0% | 26ms | 34672KB |
| 6 | WA | 0% | 27ms | 34464KB |
| 7 | WA | 0% | 26ms | 34880KB |
| 8 | AC | 100% | 25ms | 35232KB |
| 9 | WA | 0% | 26ms | 34624KB |
| 10 | WA | 0% | 26ms | 34832KB |
| 11 | WA | 0% | 30ms | 35264KB |
| 12 | WA | 0% | 28ms | 35200KB |
| 13 | WA | 0% | 30ms | 34784KB |
| 14 | WA | 0% | 28ms | 34464KB |
| 15 | WA | 0% | 29ms | 34672KB |
| 16 | WA | 0% | 26ms | 34416KB |
| 17 | WA | 0% | 27ms | 35072KB |
| 18 | WA | 0% | 27ms | 34416KB |
| 19 | WA | 0% | 35ms | 35168KB |
| 20 | WA | 0% | 34ms | 35120KB |
| 21 | WA | 0% | 27ms | 35024KB |
| 22 | WA | 0% | 44ms | 35984KB |
| 23 | WA | 0% | 27ms | 34656KB |
| 24 | WA | 0% | 65ms | 35824KB |
| 25 | WA | 0% | 35ms | 35632KB |
| 26 | WA | 0% | 44ms | 35536KB |
| 27 | WA | 0% | 64ms | 36160KB |
| 28 | WA | 0% | 34ms | 34976KB |
| 29 | WA | 0% | 198ms | 39520KB |
| 30 | WA | 0% | 44ms | 35216KB |
#https://kotamanegi.com/Problems/view/index.php?page=70
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate
#from itertools import product
from bisect import bisect_left,bisect_right
import heapq
from math import floor, ceil
#from operator import itemgetter
#inf = 10**17
#mod = 10**9 + 7
N = int(input())
t = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(N)]
inf = 10**6
#dp[s]:sは学習済みのアルゴリズム
# dp[s]はその時かかっている時間
dp = [inf]*(1<<N)
dp[0] = 0
def dfs(s):
for i in range(N):
if s>>i == 0:
hiku = 0
for j in range(N):
if s>>j & 1 == 1:
hiku += a[j][i]
ns = s |1<<i
dp[ns] = min(dp[ns], dp[s]+t[i]-hiku)
dfs(ns)
dfs(0)
print(dp[-1])
if __name__ == '__main__':
main()