input
stringlengths
20
127k
target
stringlengths
20
119k
problem_id
stringlengths
6
6
N=int(eval(input())) F=[list(map(int,input().split())) for _ in range(N)] P=[list(map(int,input().split())) for _ in range(N)] ans=-10**18 for i in range(1,2**10): tmp=0 for j in range(N): cnt=0 for k in range(10): if i&(1<<k) and F[j][k]: cnt+=1 tmp+=P[j][cnt] ans=max(ans,tmp) print(ans)
import sys input=sys.stdin.readline N=int(eval(input())) F=[int(input().replace(' ',''),2) for _ in range(N)] P=[list(map(int,input().split())) for _ in range(N)] ans=-10**18 for i in range(1,2**10): cnt=0 for j in range(N): cnt+=P[j][bin(F[j] & i).count('1')] ans=max(ans,cnt) print(ans)
p03503
n = int(eval(input())) F = [[] * 10 for _ in range(n)] P = [[] * 10 for _ in range(n)] for i in range(n): F[i] = list(map(int, input().split())) for i in range(n): P[i] = list(map(int, input().split())) res = -1<<30 for item in range(1, 1 << 10): fund = 0 for i in range(n): cnt = 0 for x in range(10): if item >> x & 1 and F[i][x] == 1: cnt += 1 fund += P[i][cnt] res = max(res, fund) print(res)
from itertools import product bit = [0, 1] lst = list(product(bit, repeat=10)) n = int(eval(input())) F = [list(map(int, input().split())) for i in range(n)] P = [list(map(int, input().split())) for j in range(n)] res = -1 << 30 for v in lst: if v.count(0) == 10: continue fund = 0 for i in range(n): cnt = 0 for x in range(10): if F[i][x] == 1 and v[x] == 1: cnt += 1 fund += P[i][cnt] res = max(res, fund) print(res)
p03503
N = int(eval(input())) F = [] P = [] for i in range(N): F.append(list(map(int, input().split()))) for i in range(N): P.append(list(map(int, input().split()))) TIME = 10 prof_cand = [] for bit in range(1,1<<TIME): onBiz = [] with_n = [] for t in range(TIME): if bit & (1<<t): onBiz.append(1) else: onBiz.append(0) for n in range(N): with_n.append(sum([F[n][i]*onBiz[i] for i in range(TIME)])) prof = sum([P[i][with_n[i]] for i in range(N)]) prof_cand.append(prof) print((max(prof_cand)))
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) def dfs(depth:int, inbis:str, f:list, p:list): if depth != 10: return max(dfs(depth+1, inbis+"1",f,p), dfs(depth+1, inbis+"0",f,p)) else: if inbis.count("1") == 0: return -10**10 else: biz = [int(i) for i in inbis] ans = 0 for i in range(len(f)): common = [biz[j]*f[i][j] for j in range(10)] ans += p[i][sum(common)] return ans n = ni() f = [] p = [] for _ in range(n): f.append(list(li())) for _ in range(n): p.append(list(li())) print((dfs(0,"",f,p)))
p03503
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) def dfs(depth:int, inbis:str, f:list, p:list): if depth != 10: return max(dfs(depth+1, inbis+"1",f,p), dfs(depth+1, inbis+"0",f,p)) else: if inbis.count("1") == 0: return -10**10 else: biz = [int(i) for i in inbis] ans = 0 for i in range(len(f)): common = [biz[j]*f[i][j] for j in range(10)] ans += p[i][sum(common)] return ans n = ni() f = [] p = [] for _ in range(n): f.append(list(li())) for _ in range(n): p.append(list(li())) print((dfs(0,"",f,p)))
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) n = ni() f = [int("".join(ls()), 2) for _ in range(n)] p = [list(li()) for _ in range(n)] # bit全探索 ans = -float("inf") for bit in range(1, 1<<10): profit = 0 for i,fi in enumerate(f): both = bin(bit&fi).count("1") profit += p[i][both] ans = max(ans, profit) print(ans)
p03503
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) n = ni() f = [int("".join(ls()), 2) for _ in range(n)] p = [list(li()) for _ in range(n)] # bit全探索 ans = -float("inf") for bit in range(1, 1<<10): profit = 0 for i,fi in enumerate(f): both = 0 for mask in range(10): if bit&(1<<mask) and fi&(1<<mask): both += 1 profit += p[i][both] ans = max(ans, profit) print(ans)
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) n = ni() f = [int("".join(ls()), 2) for _ in range(n)] p = [list(li()) for _ in range(n)] def dfs(cur:int, depth:int): if depth == 10: if cur == 0: return -float("inf") else: return sum([p[i][bin(cur&fi).count("1")] for i, fi in enumerate(f)]) else: return max(dfs(cur+(1<<depth), depth+1), dfs(cur, depth+1)) print((dfs(0,0)))
p03503
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) import itertools n = int(readline()) f = [list(map(int, readline().split())) for _ in range(n)] p = [list(map(int, readline().split())) for _ in range(n)] bit = list(itertools.product([0, 1], repeat=10)) ans = -float('inf') bit.pop(0) for i in range(2 ** 10 - 1): memo = 0 flag = False for j in range(n): cnt = 0 for k in range(10): if bit[i][k] == f[j][k] == 1: cnt += 1 if cnt != 0: flag = True memo += p[j][cnt] if flag: ans = max(ans, memo) print(ans)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) from itertools import product n = int(readline()) f = [list(map(int, readline().split())) for _ in range(n)] p = [list(map(int, readline().split())) for _ in range(n)] ans = -float('inf') for bit in list(product([0, 1], repeat=10))[1:]: v = 0 for ff, pp in zip(f, p): cnt = 0 for i, check in enumerate(ff): if bit[i] == check == 1: cnt += 1 v += pp[cnt] if ans < v: ans = v print(ans)
p03503
import sys input = sys.stdin.readline N = int(eval(input())) F = [list(map(int, input().split())) for _ in range(N)] P = [list(map(int, input().split())) for _ in range(N)] # 各曜日時間帯に開くか開かないかは2**10=1024通りしかないので # O(N*2**10) = O(10**5)で間に合う # 長さ10の配列に0 or 1を格納するbit全探索を行う。 # F[i][j]: 店i, jは曜日と時間帯を表す0~9 n = 10 max_profit = - float("inf") for bit in range(1, 1<<n): # 2**10まで2進数で(1つ以上の時間帯で営業しないといけないから000000000を除くため、1スタート) profit = 0 for i in range(N): # 店の数 count = 0 for j in range(n): # bit(10桁)のどこに1があるか調べる if F[i][j] == 1 and (bit>>j) & 1: # 右シフトしたbitの最後の桁が1ならTrue # 10回シフトして最後の桁が1か調べる == bitのj桁目に1があればTrue count += 1 profit += P[i][count] max_profit = max(max_profit, profit) print(max_profit)
N = int(eval(input())) F = [] for _ in range(N): F.append(list(map(int, input().split()))) P = [] for _ in range(N): P.append(list(map(int, input().split()))) n = 10 answer = -float("inf") for bit in range(1, 1<<n): ans = 0 for i in range(N): count = 0 for j in range(n): if F[i][j] and (bit>>j & 1): count += 1 ans += P[i][count] answer = max(ans, answer) print(answer)
p03503
I=input;n=int(I());f=[int(I()[::2],2)for _ in[0]*n];p=[I().split()for _ in[0]*n];print((max(sum(int(q[bin(i&g).count('1')])for g,q in zip(f,p))for i in range(1,1024))))
I=input;n=int(I());f=eval('int(I()[::2],2),'*n);p=eval('I().split(),'*n);print((max(sum(int(q[bin(i&g).count('1')])for g,q in zip(f,p))for i in range(1,1024))))
p03503
# coding:utf-8 INF = float('inf') def inpl(): return list(map(int, input().split())) N = int(eval(input())) F = [inpl() for _ in range(N)] P = [inpl() for _ in range(N)] ans = -INF for i in range(1, 1 << 10): score = 0 for shop in range(N): both_open = 0 for period in range(10): if i >> period & F[shop][period] == 1: both_open += 1 score += P[shop][both_open] ans = max(ans, score) print(ans)
# coding:utf-8 import sys INF = float('inf') MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def II(): return int(sys.stdin.readline()) def SI(): return eval(input()) n = II() F = [LI() for _ in range(n)] P = [LI() for _ in range(n)] ans = -INF for bit in range(1, 1024): profit = 0 for shop in range(n): cnt = 0 for shift in range(10): if not bit >> shift & 1: continue if F[shop][shift]: cnt += 1 profit += P[shop][cnt] ans = max(ans, profit) print(ans)
p03503
n = int(eval(input())) f = [list(map(int,input().split())) for i in range(n)] p = [list(map(int,input().split())) for i in range(n)] ans = -10**10 for i in range(1,2**10): a = 0 for j in range(n): a += p[j][sum(i>>k&1 and f[j][k] for k in range(10))] ans = max(ans,a) print(ans)
n = int(eval(input())) f = [list(map(int,input().split())) for i in range(n)] p = [list(map(int,input().split())) for i in range(n)] print((max(sum(p[j][sum(i>>k&1 and f[j][k] for k in range(10))] for j in range(n)) for i in range(1,2**10))))
p03503
N = int(eval(input())) F = [list(map(int,input().split())) for n in range(N)] P = [list(map(int,input().split())) for n in range(N)] ans = [] for i in range(1,1024): p = 0 for j in range(N): c = 0 for k in range(10): if (i>>k&1) & F[j][k]: c+=1 p+=P[j][c] ans+=[p] print((max(ans)))
N = int(eval(input())) F = [int("".join(input().split()),2) for n in range(N)] P = [list(map(int,input().split())) for n in range(N)] print((max(sum(p[bin(n&f).count("1")]for f,p in zip(F,P)) for n in range(1,1024))))
p03503
#N,A,B=map(int, input().split()) #A=list(map(int, input().split())) N=int(eval(input())) F=[] P=[] for i in range(N): tmp=list(map(int, input().split())) F.append(tmp) for i in range(N): tmp=list(map(int, input().split())) P.append(tmp) max_sum=-1000000001 for i in range(1,1024): bin=[0]*10 now=i for j in range(10): bin[j]=now%2 now=now//2 ans_sum=0 for j in range(N): ans=0 for h in range(10): if F[j][h]*bin[h]==1: ans+=1 ans_sum+=P[j][ans] if max_sum<ans_sum: max_sum=ans_sum print(max_sum)
#-*-coding:utf-8-*- def main(): n = int(eval(input())) f_list = [list(map(int, input().split())) for i in range(n)] p_list = [list(map(int, input().split())) for i in range(n)] max_profit = -1000000001 for i in range(1, 2 ** 10): binary=[0]*10 now=i for j in range(10): binary[j]=now%2 now=now//2 profit = 0 for j in range(n): one_cnt = 0 for h in range(10): if f_list[j][h]*binary[h]==1: one_cnt += 1 profit += p_list[j][one_cnt] if max_profit < profit: max_profit = profit print(max_profit) if __name__ == '__main__': main()
p03503
N = int(eval(input())) isopen = [list(map(int,input().split())) for i in range(N)] gain = [list(map(int,input().split())) for i in range(N)] ans = -float('inf') for i in range(1,2**10): tmp = 0 for n in range(N): c = 0 for b in range(10): if ((i >> b)&1) & isopen[n][b]: c += 1 tmp += gain[n][c] ans = max(ans, tmp) print(ans)
N = int(eval(input())) F = [list(map(int,input().split())) for i in range(N)] P = [list(map(int,input().split())) for i in range(N)] ans = -float('inf') for b in range(1,2**10): tmp = 0 for i in range(N): c = 0 for k in range(10): if b&(1<<k) and F[i][k]: c += 1 tmp += P[i][c] ans = max(ans,tmp) print(ans)
p03503
N = int(eval(input())) fs = [list(map(int,input().split())) for i in range(N)] ps = [list(map(int,input().split())) for i in range(N)] INF = float('inf') ans = -INF for b in range(1,2**10): tmp = 0 for f,p in zip(fs,ps): c = 0 for k in range(10): if b&(1<<k)==0: continue if f[k]: c += 1 tmp += p[c] ans = max(ans, tmp) print(ans)
N = int(eval(input())) F = [list(map(int,input().split())) for i in range(N)] P = [list(map(int,input().split())) for i in range(N)] ans = -float('inf') for k in range(1,1<<10): tmp = 0 for fs,ps in zip(F,P): cnt = 0 for b in range(10): if (k>>b)&1 and fs[b]: cnt += 1 tmp += ps[cnt] ans = max(ans, tmp) print(ans)
p03503
N = int(eval(input())) F = [[int(i) for i in input().split()] for i in range(N)] P = [[int(i) for i in input().split()] for i in range(N)] ans = - 10 ** 16 for i in range(1 << 10): output = [0] * 10 for j in range(10): if (i>>j) & 1: output[j] = 1 if output.count(0) == 10: continue tmp_sum = 0 for n in range(N): cnt = 0 for m in range(10): if F[n][m] == output[m] == 1: cnt += 1 tmp_sum += P[n][cnt] ans = max(ans, tmp_sum) print(ans)
def main(): N = int(eval(input())) F = [list(map(int, input().split())) for _ in range(N)] P = [list(map(int, input().split())) for _ in range(N)] ans = -(10**15) for i in range(2**10): tmp = [] for j in range(10): if ((i >> j) & 1): tmp.append(j) if not tmp: continue score = 0 for k in range(N): cnt = 0 for l in range(10): if F[k][l] == 1 and l in tmp: cnt += 1 score += P[k][cnt] ans = max(ans, score) print(ans) if __name__ == "__main__": main()
p03503
n = int(eval(input())) flst = [] for _ in range(n): flst.append([int(i) for i in input().split()]) plst = [] for _ in range(n): plst.append([int(i) for i in input().split()]) m = - 1 << 30 for i in range(1, 1 << 10): r = 0 for j in range(n): c = 0 for k in range(10): if (i >> k & 1) & flst[j][k]: c += 1 r += plst[j][c] m = max(m, r) print(m)
n = int(eval(input())) flst = [] for _ in range(n): flst.append(int(''.join(input().split()), 2)) plst = [] for _ in range(n): plst.append([int(i) for i in input().split()]) m = - 1 << 30 for i in range(1, 1 << 10): r = 0 for j in range(n): s = i & flst[j] c = 0 while s: s &= s - 1 c += 1 r += plst[j][c] m = max(m, r) print(m)
p03503
n = int(eval(input())) f = [input().replace(" ", '') for _ in range(n)] p = [list(map(int, input().split())) for _ in range(n)] outcome_list = [] for i in range(1, 1 << 10): outcome = 0 for j, x in enumerate(f): both = "{:010b}".format(i & int(x, 2)) n_store = sum(map(int, list(both))) outcome += p[j][n_store] outcome_list.append(outcome) print((max(outcome_list)))
N = int(eval(input())) F = [int(input().replace(" ", ''), 2) for _ in range(N)] P = [list(map(int, input().split())) for _ in range(N)] outcome_list = [] for i in range(1, 1 << 10): outcome = 0 for f, p in zip(F, P): n_store = "{:010b}".format(i & f).count("1") outcome += p[n_store] outcome_list.append(outcome) print((max(outcome_list)))
p03503
from sys import stdin input = stdin.readline MAX_TIME = 10 N = int(eval(input())) F = [[int(j) for j in input().split()] for i in range(N)] P = [[int(j) for j in input().split()] for i in range(N)] def main(): ans = -11000000001 # 営業時間帯 最低でも ひとつの時間帯 # 選択パターン for i in range(1, 2 ** MAX_TIME): tmp = 0 # 他の店 for j in range(N): # 各時間帯 cnt = sum([F[j][k] for k in range(MAX_TIME) if i >> k & 1]) tmp += P[j][cnt] ans = max(ans, tmp) print(ans) return main()
MAX_TIME = 10 N = int(eval(input())) F = [int(input().replace(" ", ""), 2) for i in range(N)] P = [[int(j) for j in input().split()] for i in range(N)] def main(): # 1 から 2 ** MAX_TIME - 1 # 営業時間帯 最低でも ひとつの時間帯 # 選択する時間帯を2進法で表現したもの # F[店のインデックス] # 他の店 # 選択する時間帯を2進法で表現したもの # P[店のインデックス][合致した時間帯の数] # 利益 print((max(sum( [p[bin(f & i).count("1")] for f, p in zip(F, P)]) for i in range(1, 2 ** MAX_TIME)))) return main()
p03503
n = int(eval(input())) shops = [list(input().split()) for i in range(n)] profits = [list(input().split()) for i in range(n)] l = [] ans = -10000000000000000000000000000 def f(now, i): if i >= 10: l.append(list(now)) return f(now+"1", i+1) f(now+"0", i+1) f("", 0) for i in range(len(l)-1): temp = 0 for j in range(len(shops)): count = 0 for k in range(10): if shops[j][k] == "1" and l[i][k] == "1": count += 1 temp += int(profits[j][count]) if temp > ans: ans = temp print(ans)
import itertools n = int(eval(input())) F = [list(map(int, input().split())) for i in range(n)] P = [list(map(int, input().split())) for i in range(n)] combos = sorted(list(itertools.product([0, 1], repeat=10))) ans = -float('inf') for combo in combos[1:]: total = 0 for i in range(len(F)): count = 0 for a, b in zip(combo, F[i]): if a == 1 and b == 1: count += 1 total += P[i][count] ans = max(ans, total) print(ans)
p03503
N=int(eval(input())) F=[tuple(map(int,input().split())) for _ in range(N)] P=[tuple(map(int,input().split())) for _ in range(N)] ans=-(10**7*N) #営業パターンを10bitの整数であらわす(0はない) for o in range(1,1<<10): #同時に営業する時間帯数のリスト C=[0]*N for t in range(10): #時間帯tに営業するか if o&1: for i in range(N): if F[i][t]==1: C[i]+=1 o>>=1 #利益を計算 p=0 for i in range(N): p+=P[i][C[i]] ans=max(ans,p) print(ans)
N=int(eval(input())) F=[int(input().replace(' ',''),2) for _ in range(N)] P=[tuple(map(int,input().split())) for _ in range(N)] ans=-(10**7*N) for o in range(1,1<<10): p=0 for i in range(N): p+=P[i][bin(F[i]&o).count('1')] ans=max(ans,p) print(ans)
p03503
N = int(eval(input())) Flists = [list(map(int, input().split())) for _ in range(N)] Plists = [list(map(int, input().split())) for _ in range(N)] ans = -10**9 for i in range(1, 2**10): open = [] for j in range(10): if ((i>>j) & 1): open.append(1) else: open.append(0) money = 0 for num in range(N): Flist = Flists[num] same = sum([int(open[_] and Flist[_]) for _ in range(10)]) money += Plists[num][same] ans = max(ans, money) print(ans)
N = int(eval(input())) F = [int("".join(input().split()), 2) for _ in range(N)] P = [list(map(int, input().split())) for _ in range(N)] # for i in range(N): # print(bin(F[i])) ans = -10**9 for bit in range(1, 1<<10): money = 0 for i in range(N): cnt = format(bit&F[i], 'b').count('1') money += P[i][cnt] ans = max(money, ans) print(ans)
p03503
def main(): import sys #input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import Counter from collections import deque #dxy = [[0,1],[0,-1],[1,0],[-1,0]] #dxy = [[0,1],[0,-1],[1,0],[-1,0],[1,1],[1,-1],[-1,1],[-1,-1]] #mod = 1000000007 n = int(eval(input())) F = [input().split() for _ in range(n)] P = [list(map(int, input().split())) for _ in range(n)] ans = -10**10 for i in range(1, 1033): a = list(str(format(i, '010b'))) total = 0 for j in range(n): cnt = 0 for k in range(10): if F[j][k]=='1' and a[k]=='1': cnt += 1 total += P[j][cnt] if total>ans: ans = total print(ans) if __name__ == '__main__': main()
N=int(eval(input())) SO=[int(input().replace(' ',''), 2) for i in range(N)] PT=[list(map(int,input().split())) for i in range(N)] ret=-10**7*N for sp in range(1,2**10): r=0 for i in range(N): r+=PT[i][bin(SO[i] & sp).count('1')] ret=max(ret,r) print(ret)
p03503
N=int(eval(input())) SO=[int(input().replace(' ',''), 2) for i in range(N)] PT=[list(map(int,input().split())) for i in range(N)] ret=-10**7*N for sp in range(1,2**10): r=0 for i in range(N): r+=PT[i][bin(SO[i] & sp).count('1')] ret=max(ret,r) print(ret)
n = int(eval(input())) F = [int(input().replace(' ',''), 2) for _ in range(n)] P = [list(map(int, input().split())) for _ in range(n)] ans=-10**7*n for sp in range(1, 2**10): total = 0 for i in range(n): total += P[i][bin(F[i] & sp).count('1')] ans = max(ans, total) print(ans)
p03503
n = int(eval(input())) f = [list(map(int, input().split())) for _ in range(n)] p = [list(map(int, input().split())) for _ in range(n)] ans = -float("inf") for i in range(1, 2 ** 10): i_bin = "{:010b}".format(i) sm = 0 for shop_i in range(n): cnt = 0 for j, dig in enumerate(i_bin): if f[shop_i][j] * int(dig):# == 1 cnt += 1 sm += p[shop_i][cnt] ans = max(ans, sm) print(ans)
from itertools import combinations n = int(eval(input())) f = [list(map(int, input().split())) for _ in range(n)] p = [list(map(int, input().split())) for _ in range(n)] ans = - 10 ** 18 for i in range(1, 11): for pat in combinations(list(range(10)), i): cnt = [0] * n for e in pat: for j in range(n): cnt[j] += f[j][e] score = 0 for i, e in enumerate(cnt): score += p[i][e] ans = max(ans, score) print(ans)
p03503
n=int(eval(input())) f=[0]*n for i in range(n): x=list(map(int,input().split())) for j in range(len(x)): if x[j]==1: f[i]+=1<<j p=[[0 for j in range(10)] for i in range(n)] for i in range(n): p[i]=list(map(int,input().split())) ans=10**9*(-1)-1 for i in range(1,2**10): pro=0 for j in range(len(f)): open=0 for k in range(10): if (i>>k)&1==1 and (f[j]>>k)&1==1: open+=1 pro+=p[j][open] if ans<pro: ans=pro print(ans)
# 曜日と時間帯の組み合わせを1111111111の10ビットで全探索 import sys readline = sys.stdin.readline N = int(readline()) F = [None] * N for i in range(N): F[i] = int(readline().rstrip().replace(" ",""),2) P = [None] * N for i in range(N): P[i] = list(map(int,readline().split())) ans = -(10 ** 10) for i in range(1, 2 ** 10): # joisinoが営業する時間帯の文字列11011101 # 各店について、店jとANDを取って、1ビットの数を数えるとCが分かる point = 0 for j in range(N): # 店j debug = False c = bin(i & F[j])[2:].count("1") point += P[j][c] if ans < point: ans = point print(ans)
p03503
ans = -10 ** 9 A = [0] * 10 def func(): if sum(A) == 0: return score = 0 for i in range(N): days = sum([a * f for a, f in zip(A, F[i])]) score += P[i][days] global ans ans = max(ans, score) def dfs(pos): if pos == 10: func() return A[pos] = 0 dfs(pos + 1) A[pos] = 1 dfs(pos + 1) N = int(eval(input())) F = [] for i in range(N): F.append(list(map(int, input().split()))) P = [] for i in range(N): P.append(list(map(int, input().split()))) dfs(0) print(ans)
def calc(days): if sum(days) == 0: return profit = 0 for i in range(N): both = 0 for f, d in zip(F[i], days): if f == d == 1: both += 1 profit += P[i][both] global ans ans = max(ans, profit) def dfs(days): if len(days) == 10: calc(days) return dfs(days + [0]) dfs(days + [1]) ans = 10 ** 9 * (-1) N = int(eval(input())) F = [list(map(int, input().split())) for _ in range(N)] P = [list(map(int, input().split())) for _ in range(N)] dfs([]) print(ans)
p03503
import itertools N = int(eval(input())) F = [list(map(int,input().split())) for i in range(N)] P = [list(map(int,input().split())) for i in range(N)] b = [0,1] ans = -float('inf') for e in itertools.product(b,repeat=10): e = list(e) if e == [0]*10: continue res = 0 for i in range(N): cnt = 0 for j in range(10): if e[j] == 1 and F[i][j] == 1: cnt += 1 res += P[i][cnt] if res > ans: ans = res print(ans)
import itertools inf = float('inf') N = int(eval(input())) F = [list(map(int,input().split())) for _ in range(N)] P = [list(map(int,input().split())) for _ in range(N)] ans = -inf for shift in itertools.product([0,1],repeat=10): if not any(shift): continue res = 0 for i,line in enumerate(F): c = 0 for s, f in zip(shift, line): if s and f: c += 1 res += P[i][c] if res > ans: ans = res print(ans)
p03503
n = int(eval(input())) v = [int(i) for i in input().split()] c = [int(i) for i in input().split()] max_v_minus_c = 0 for i in range(2**n): flugs = bin(i)[2:].zfill(n) sum_v = 0 sum_c = 0 j = 0 for flug in str(flugs): if flug == '1': sum_v += v[j] sum_c += c[j] j += 1 if (max_v_minus_c < sum_v - sum_c): max_v_minus_c = sum_v - sum_c print(max_v_minus_c)
n = int(eval(input())) v_list = [int(i) for i in input().split()] c_list = [int(i) for i in input().split()] b_list = [v - c for (v, c) in zip(v_list, c_list)] print((sum([b for b in b_list if b > 0])))
p03060
n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) xy = [x-y for (x,y) in zip(v,c)] sm = 0 for x in xy: if x>0: sm += x print(sm)
n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) xy = [x-y for (x,y) in zip(v,c)] sm = 0 for x in xy: sm = sm+x if x>0 else sm+0 print(sm)
p03060
N = int(eval(input())) V = [int(n) for n in input().split()] C = [int(n) for n in input().split()] take = [0 for _ in range(N)] ans = 0 def up(i): if i == N: return False take[i] += 1 if take[i] == 2: take[i] = 0 return up(i + 1) return True while True: sum = 0 for i in range(N): if take[i] == 1: sum += V[i] - C[i] if sum > ans: ans = sum if not up(0): break print(ans)
N = int(eval(input())) V = [int(n) for n in input().split()] C = [int(n) for n in input().split()] ans = 0 for i in range(N): ans = max([ans, ans + V[i] - C[i]]) print(ans)
p03060
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) maxV = 0 for i in range(2**N): bit = i X = Y = 0 for j in range(N): mod = bit%2 bit = bit//2 if(mod==1): X += V[j] Y += C[j] maxV = max(maxV, X-Y) print(maxV)
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) X = [max(0, V[i]-C[i]) for i in range(N)] print((sum(X)))
p03060
def main(): g = [] n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) for i in range(n): gain = v[i] -c[i] if gain > 0 : g.append(gain) print((sum(g))) if __name__ == '__main__': main()
def main(): g = 0 n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) for i in range(n): gain = v[i] -c[i] if gain > 0 : g += gain print(g) if __name__ == '__main__': main()
p03060
N = int(eval(input())) V = list(map(int,input().split())) C = list(map(int,input().split())) x = 0 y = 0 mx = 0 for i in range(2**N): x = 0 y = 0 for j in range(N): if (i >> j) & 1 == 1: x += V[j] y += C[j] mx = max(x-y,mx) print(mx)
N = int(eval(input())) V = list(map(int,input().split())) C = list(map(int,input().split())) x = 0 y = 0 mx = 0 l = [V[i]-C[i] for i in range(N)] print((sum([ i for i in l if i>0 ])))
p03060
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) x = 0 y = 0 for i in range(n): if v[i] - c[i] > 0: x += v[i] y += c[i] print((x-y))
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) x = 0 y = 0 # 価値とコストが0以上である宝石を選ぶ。 for i in range(n): if v[i] - c[i] > 0: x += v[i] y += c[i] # 選択した宝石の価値とコストの総和差の計算。 print((x-y))
p03060
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) ans = 0 for i in range(1<<N): val = 0 for j in range(N): if i >> j & 1: val+=V[j] val-=C[j] ans = max(ans, val) print(ans)
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) ans = 0 for i in range(2**N): val = 0 for j in range(N): if (i >> j) & 1: val+=V[j] val-=C[j] ans = max(ans, val) print(ans)
p03060
import itertools N = int(eval(input())) V = [int(i) for i in input().split()] C = [int(i) for i in input().split()] max = 0 pattern = itertools.product(list(range(2)), repeat=N) for p in pattern: sum = 0 count = 0 for i in p: if i == 1: sum += V[count]-C[count] else: pass count +=1 if sum > max: max = sum print(max)
import itertools N = int(eval(input())) V = [int(i) for i in input().split()] C = [int(i) for i in input().split()] sum = 0 for i in range(N): if V[i]-C[i] > 0: sum += V[i]-C[i] print(sum)
p03060
# coding: utf-8 import itertools n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) d = sum(v) - sum(c) maxd = d if d > 0 else 0 for m in range(1, n): a0 = [i for i in list(itertools.combinations(list(range(n)), m))] for a1 in a0: d = sum([v[j] - c[j] for j in a1]) if maxd < d: maxd = d print(maxd)
# coding: utf-8 import itertools n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) d = sum([v[i] - c[i] for i in range(n) if v[i] - c[i] > 0]) print(d)
p03060
from itertools import combinations n = int(eval(input())) value = list(map(int, input().split())) cost = list(map(int, input().split())) idx = list(range(n)) result = [0, sum(value)-sum(cost)] comb = [com for i in range(1, n) for com in combinations(idx, i)] for com in comb: tmp = 0 for c in com: tmp += value[c]-cost[c] result.append(tmp) print((max(result)))
n = int(eval(input())) value = list(map(int, input().split())) cost = list(map(int, input().split())) result = 0 for v, c in zip(value, cost): if v > c: result += v-c print(result)
p03060
n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) list = [0] x, y = 0, 0 v_sort = sorted(v,reverse = True) c_sort = sorted(c,reverse = True) for i in range(len(v)): if v[i] > c[i]: x += int(v[i]) y += int(c[i]) list.append(x - y) else: continue print((max(list)))
n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) list = [0] x, y = 0, 0 for i in range(len(v)): if v[i] > c[i]: x += int(v[i]) y += int(c[i]) list.append(x - y) else: continue print((max(list)))
p03060
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) import itertools bit = list(itertools.product([0,1], repeat=n)) ans = [] for i in range(2 ** n): arr = list(bit[i]) x = 0 y = 0 for j in range(len(arr)): if arr[j] == 1: x += v[j] y += c[j] ans.append(x-y) print((max(ans)))
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) count = 0 for i in range(n): if v[i] >= c[i]: count += v[i] - c[i] print(count)
p03060
n=int(eval(input())) v=list(map(int,input().split())) c=list(map(int,input().split())) h=[] for x,y in zip(v,c): h.append(x-y) ans=0 for i in h: if i>=0: ans+=i print(ans)
n=eval(input()) v=list(map(int,input().split())) c=list(map(int,input().split())) ans=0 for i,j in zip(v,c): if i-j>0: ans+=(i-j) print(ans)
p03060
n=int(eval(input())) v=[*list(map(int,input().split()))] c=[*list(map(int,input().split()))] print((sum(max(x-y,0) for x,y in zip(v,c))))
eval(input()) f=lambda:list(map(int,input().split())) print((sum(max(x-y,0) for x,y in zip(f(),f()))))
p03060
n=int(eval(input())) v=list(map(int,input().split())) c=list(map(int,input().split())) x=0 for i in range(2**n): cost=0 value=0 for j in range(n): if i>>j&1: cost+=c[j] value+=v[j] else: if value-cost>x: x=value-cost print(x)
n=int(eval(input())) v=list(map(int,input().split())) c=list(map(int,input().split())) ans=0 for i in range(n): if v[i]-c[i]>=1: ans+=v[i]-c[i] print(ans)
p03060
import itertools N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) diff =[V[n] - C[n] for n in range(N)] XY = 0 for v in itertools.permutations([0, 1] * N, N): xy = 0 for n in range(N): xy += diff[n] * v[n] if xy > XY: XY = xy print(XY)
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) diff = [0] for n in range(N): if V[n] - C[n] > 0: diff.append(V[n] - C[n]) print((sum(diff)))
p03060
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float('inf') def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) n = I() v = LI() c = LI() lst = [v[i]-c[i] for i in range(n)] ans = 0 for i in range(n): if lst[i] >= 0: ans += lst[i] print(ans)
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float('inf') def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) n = I() v = LI() c = LI() ans = 0 for i in range(n): if v[i] > c[i]: ans += v[i] - c[i] print(ans)
p03060
from itertools import product N = int(eval(input())) *V, = list(map(int, input().split())) *C, = list(map(int, input().split())) ans = -10**18 for p in product([0, 1], repeat=N): res = 0 for i, e in enumerate(p): if e: res += V[i] - C[i] ans = max(ans, res) print(ans)
N = int(eval(input())) *V, = list(map(int, input().split())) *C, = list(map(int, input().split())) ans = 0 for v, c in zip(V, C): if v > c: ans += v-c print(ans)
p03060
n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) bit = 0b0 ans = 0 for i in range(2**n): bag = [] cost = [] for j in range(n): if(((bit >> j) & 1) == 1): bag.append(v[j]) cost.append(c[j]) else: bag.append(0) cost.append(0) p = sum(bag) - sum(cost) if(p > ans): ans = p bit += 1 print(ans)
n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) bag = 0 for i in range(n): if(c[i] <= v[i]): bag += v[i] - c[i] print(bag)
p03060
N = int(eval(input())) V = [int(x.strip()) for x in input().split()] C = [int(x.strip()) for x in input().split()] Z = [0 for i in range(2**N)] for i in range(1, 2**N): select = [] temp = i for n in reversed(list(range(1, N+1))): if temp - 2**(n-1) >= 0: temp = temp - 2**(n-1) select.append(n-1) Z[i] = sum([V[j] for j in select]) - sum([C[j] for j in select]) print((max(Z)))
N = int(eval(input())) V = [int(x.strip()) for x in input().split()] C = [int(x.strip()) for x in input().split()] Z = [V[i] - C[i] for i in range(N)] print((sum([z for z in Z if z > 0])))
p03060
import itertools n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) xy = [] for i in range(1,n+1): for h in itertools.combinations(list(range(0,n)),i): x = 0 y = 0 for j in h: x += v[j] y += c[j] xy.append(x-y) if max(xy) < 0: print((0)) else: print((max(xy)))
import itertools n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) xy = 0 for i in range(1,n+1): for h in itertools.combinations(list(range(0,n)),i): x = 0 y = 0 for j in h: x += v[j] y += c[j] if xy < x-y: xy = x-y print(xy)
p03060
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ # ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ # ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬╬╬╬╬ # ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬ ╬ # ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬╬ # ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬ ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬ # ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬ ╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╬ ╬ # ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬ ╬╬╬╬╬╬╬ ╬ ╬╬╬╬ ╬╬╬╬ # ╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬╬ ╬ ╬╬╬╬╬╬╬╬╬ ╬ ╬ ╬╬ ╬╬╬ # ╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬ ╬╬╬ ╬ ╬╬╬ ╬ ╬╬ ╬╬╬╬╬╬╬╬ # ╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬ ╬ ╬╬╬╬╬╬╬╬ ╬╬╬ # ╬╬ ╬╬╬ ╬╬╬╬ ╬╬╬╬╬ ╬╬╬╬╬╬╬ ╬╬ ╬╬╬╬ ╬ ╬ # ╬╬ ╬ ╬╬╬╬╬╬╬╬╬╬╬ ╬ ╬╬╬╬ ╬ ╬╬╬ ╬ # ╬╬ ╬╬╬╬╬ ╬ ╬ ╬╬ ╬ # ╬╬ ╬╬╬╬╬╬╬╬ ╬╬ ╬ # ╬╬ ╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬ ╬ # ╬╬╬╬ ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬ # ╬╬╬╬╬ ╬╬╬╬╬ ╬ # ╬╬╬╬╬╬╬ ╬╬╬ # ╬╬╬╬╬╬╬╬╬╬ ╬ ╬╬╬╬╬╬╬╬ # ╬╬╬╬╬╬╬╬╬ ╬ ╬ ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬ # ╬╬╬╬╬╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬ # ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╬ # ╬ ╬╬╬╬╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╬ n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) ans = 0 for i in range(n): if v[i] - c[i] > 0: ans += v[i] - c[i] print(ans)
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.....╬╬............ # ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬..╬.╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.....╬.......... # ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬..╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.╬....╬╬╬╬╬╬╬...╬╬╬╬╬╬╬╬╬╬......╬...... # ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬..╬...╬╬╬╬╬╬╬..╬......╬╬╬╬..╬╬╬╬........ # ╬╬╬╬╬╬╬╬╬╬╬╬╬.╬╬.╬....╬╬╬╬╬╬╬╬╬........╬.╬........╬╬.╬╬╬.................... # ╬╬╬╬╬╬╬╬╬╬╬╬╬╬....╬.....╬╬╬...........╬.╬╬╬....╬..╬╬..╬╬╬╬╬╬╬╬.............. # ╬╬╬╬╬╬.╬╬╬╬╬╬╬╬........................╬╬╬╬╬╬╬╬╬..╬...╬╬╬╬╬╬╬╬...╬╬╬........ # ╬╬..╬╬╬..╬╬╬╬.....╬╬╬╬╬..................╬╬╬╬╬╬╬.......╬╬.╬╬╬╬..╬....╬...... # ╬╬......╬...╬╬╬╬╬╬╬╬╬╬╬.╬.................╬╬╬╬.........╬..╬╬╬...........╬... # ╬╬.......╬╬╬╬╬....╬..................................╬....╬╬...............╬ # ╬╬.....╬╬╬╬╬╬╬╬....................................╬╬....╬.................. # ╬╬.....╬╬╬╬╬╬╬╬╬╬╬╬╬╬......................╬..........╬..................... # ╬╬╬╬..╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬......................................╬................ # ╬╬╬╬╬.......╬╬╬╬╬..........................................╬................ # ╬╬╬╬╬╬╬....................................╬╬╬.............................. # ╬╬╬╬╬╬╬╬╬╬..........................╬..╬╬╬╬╬╬╬╬............................. # ╬╬╬╬╬╬╬╬╬.╬..╬..................╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.........╬................... # ╬╬╬╬╬╬╬╬╬╬╬╬..................╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬........╬.................... # ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬................╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.......╬...................... # ╬....╬╬╬╬╬╬╬╬╬╬╬.................╬╬╬╬╬╬╬╬╬╬................................. # ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬........................................................... # ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.╬╬...........................╬............................ n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) ans = 0 for i in range(n): if v[i] - c[i] > 0: ans += v[i] - c[i] print(ans)
p03060
n = int(eval(input())) V = list(map(int,input().split())) C = list(map(int,input().split())) s = [] for i in range(n): s.append(V[i]-C[i]) s.sort(reverse=True) res = 0 for a in s: if a >= 0: res += a print(res)
n = int(eval(input())) V = list(map(int,input().split())) C = list(map(int,input().split())) res = 0 for i in range(n): s = V[i] - C[i] if s > 0: res += s print(res)
p03060
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) result = 0 for i in range(n): if v[i] > c[i]: result += v[i] - c[i] print(result)
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) print((sum([V[i] - C[i] for i in range(N) if V[i] > C[i]])))
p03060
n = int(eval(input())) v = [num for num in map(int, input().split())] c = [num for num in map(int, input().split())] ans = 0 for i in range(n): val = v[i] - c[i] if val > 0: ans += val print(ans)
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) ans = 0 for i in range(n): if v[i] > c[i]: ans += v[i] - c[i] print(ans)
p03060
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) D = [V[i] - C[i] for i in range(N)] ans = 0 for i in range(N): if D[i] > 0: ans += D[i] print(ans)
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) ans = 0 for i in range(N): tmp = V[i] - C[i] if tmp > 0: ans += tmp print(ans)
p03060
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) ans = 0 for i in range(2**n): # test = [] X, Y = 0, 0 for j in range(n): if (i >> j) & 1 == 1: X += v[j] Y += c[j] # test.append([v[j], c[j]]) if ans < X - Y: ans = X - Y # print(test) print(ans)
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) ans = 0 for vi, ci in zip(v, c): if vi >= ci: ans += vi - ci print(ans)
p03060
import itertools n=int(eval(input())) lis=[list(map(int,input().split())) for _ in range(2)] ans=0 for li in itertools.product([0,1], repeat=n): v=0 for id,l in enumerate(li): if l: v += lis[0][id] - lis[1][id] if v > ans: ans=v print(ans)
n,a=int(eval(input())),0 V=list(map(int,input().split())) C=list(map(int,input().split())) ans=[0 for _ in range(n)] for i in range(n): ans = V[i] - C[i] if ans > 0: a += ans print(a)
p03060
import itertools def bit_patterns(n): return list(itertools.product(list(range(2)), repeat=n)) def actual(n, V, C): diff_list = [] for bit_pattern in bit_patterns(n): values = sum([bit * value for bit, value in zip(bit_pattern, V)]) costs = sum([bit * cost for bit, cost in zip(bit_pattern, C)]) diff_list.append(values - costs) return max(diff_list) n = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) print((actual(n, V, C)))
def actual(n, V, C): # 購入するとプラスになるものだけ買って合計でおk sale_jewels = [] for v, c in zip(V, C): if v - c > 0: sale_jewels.append(v - c) return sum(sale_jewels) # return sum([v - c for v, c in zip(V, C) if v - c > 0]) n = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) print((actual(n, V, C)))
p03060
import itertools n=int(eval(input())) v=[int(i) for i in input().split()] c=[int(i) for i in input().split()] ans=[v[i]-c[i] for i in range(n)]+[0] x=[i for i in range(n)] for i in range(2,n): for z in itertools.combinations(x, i): A=0 for y in z: A+=v[y]-c[y] ans+=[A] print((max(ans)))
n=int(eval(input())) v=[int(i) for i in input().split()] c=[int(i) for i in input().split()] ans=[v[i]-c[i] for i in range(n)] ans.sort(reverse=True) A=0 for i in ans: if i>0: A+=i else: break print(A)
p03060
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) ans = [] for i in range(0, 2 ** N): x = 1 a = 0 for n in range(N): if i & x: a += V[n] - C[n] x = x << 1 ans.append(a) print((max(ans)))
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) ans = 0 for i in range(N): x = V[i] - C[i] if x > 0: ans += x print(ans)
p03060
n = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) from itertools import product max_total = 0 for lis in product((0, 1), repeat=n): total = 0 for i, zero_one in enumerate(lis): total += (V[i]-C[i]) * zero_one max_total = max(max_total, total) print(max_total)
n = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) total = 0 for i in range(n): if V[i] - C[i] > 0: total += V[i] - C[i] print(total)
p03060
from itertools import product n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) a = list(product([0, 1], repeat=n)) m = 0 xsum = 0 ysum = 0 for i in range(len(a)): for j in range(n): if a[i][j] == 1: xsum += v[j] ysum += c[j] difxy = xsum - ysum if difxy > m: m = difxy xsum = 0 ysum = 0 print(m)
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) m = 0 for i in range(n): difxy = v[i] - c[i] if difxy > 0: m += difxy print(m)
p03060
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) # 2進数のカウンターを使って全探索する ans = 0 cnt = 0 # カウンター def get_value(b): """ バイナリ値bを受け取り、X-Yを計算する """ X = 0 Y = 0 for i in range(N): if b[i] == "1": X += V[i] Y += C[i] return X - Y while cnt < 2 ** N: b = bin(cnt)[2:] ans = max(ans, get_value("0" * (N - len(b)) + b)) cnt += 1 print(ans)
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) # V_i > C_iなら選ぶ ans = 0 # 価値の合計 for i in range(N): if V[i] > C[i]: ans += V[i] - C[i] print(ans)
p03060
def weight( n, lst ): l = len(lst) wei = 0 for i in range(N): if n % 2 == 1: wei += lst[l-i-1] n = n // 2 return wei N = int(eval(input())) Vlist = list(map(int,input().split())) Clist = list(map(int,input().split())) maxval = 0 for i in range(2 ** N): vsum = weight(i,Vlist) csum = weight(i,Clist) gain = vsum - csum if i == 0: maxval = gain else: if maxval < gain: maxval = gain print(maxval)
N = int(eval(input())) Vlist = list(map(int,input().split())) Clist = list(map(int,input().split())) sum1 = 0 for i in range(N): x = Vlist[i] c = Clist[i] if x - c > 0: sum1 += (x-c) print(sum1)
p03060
import itertools N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) n = [i for i in range(N)] ind = [] for i in range(1, N + 1): ind += list(itertools.combinations(n, i)) # print(ind) M = len(ind) ans = 0 for val in ind: X = 0 Y = 0 for v in val: X += V[v] Y += C[v] c = X - Y ans = max(ans, c) print(ans)
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) ans = 0 for i in range(N): X = V[i] - C[i] if X > 0: ans += X print(ans)
p03060
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) import itertools #n桁のm値のbitを生成 def bit(n, m): bit_list = list(itertools.product([i for i in range(m)], repeat=n)) return bit_list bts = bit(N, 2) res = 0 for b in bts: tmp = 0 for i in range(N): if b[i] == 0: tmp += V[i] - C[i] if tmp > res: res = tmp print(res)
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) tmp = [0 for _ in range(N)] for i in range(N): tmp[i] = V[i] - C[i] res = 0 for i in range(N): if tmp[i] > 0: res += tmp[i] print(res)
p03060
import itertools n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) l = [True, False] max_diff_v_c = 0 for flags in itertools.product(l, repeat=n): # print(' '.join(map(str, flags))) sum_v = 0 sum_c = 0 for i in range(len(flags)): if flags[i]: sum_v += v[i] sum_c += c[i] diff_v_c = sum_v - sum_c if max_diff_v_c < diff_v_c: max_diff_v_c = diff_v_c print(max_diff_v_c)
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) max_diff_v_c = 0 for i in range(n): diff_v_c = v[i] - c[i] if diff_v_c > 0: max_diff_v_c += diff_v_c print(max_diff_v_c)
p03060
def main(): n = int(eval(input())) v = [int(v) for v in input().split()] c = [int(c) for c in input().split()] max_total = 0 for i in range(2 ** n): total = 0 for j in range(n): # このループが一番のポイント if ((i >> j) & 1): # 順に右にシフトさせ最下位bitのチェックを行う total += v[j] total -= c[j] if total > max_total: max_total = total print(max_total) if __name__ == '__main__': main()
def main(): n = int(eval(input())) v = [int(v) for v in input().split()] c = [int(c) for c in input().split()] total = 0 for nn in range(n): if v[nn] > c[nn]: total += v[nn] total -= c[nn] print(total) # max_total = 0 # for i in range(2 ** n): # total = 0 # for j in range(n): # このループが一番のポイント # if ((i >> j) & 1): # 順に右にシフトさせ最下位bitのチェックを行う # total += v[j] # total -= c[j] # if total > max_total: # max_total = total # print(max_total) if __name__ == '__main__': main()
p03060
import itertools N = int(eval(input())) value_list = list(map(int, input().split())) cost_list = list(map(int, input().split())) value_result = [] for i in range(1,len(value_list)+1): for conb in itertools.combinations(value_list, i): value_result.append(list(conb)) cost_result = [] for i in range(1,len(cost_list)+1): for conb in itertools.combinations(cost_list, i): cost_result.append(list(conb)) ans_list = [] for i in range(len(value_result)): ans = sum(value_result[i]) - sum(cost_result[i]) ans_list.append(ans) if max(ans_list) > 0: print((max(ans_list))) else: print((0))
N = int(eval(input())) value_list = list(map(int, input().split())) cost_list = list(map(int, input().split())) total = 0 for i in range(N): ans = value_list[i] - cost_list[i] if ans > 0: total += ans print(total)
p03060
N=int(eval(input())) V=list(map(int, input().split())) C=list(map(int, input().split())) a=[] for i in range(1<<N): tmp=0 for j in range(N): if ((i >> j) & 1) == 1: tmp+=V[j]-C[j] a.append(tmp) print((max(a)))
N=int(eval(input())) V=list(map(int, input().split())) C=list(map(int, input().split())) a=0 for i in range(N): if V[i]-C[i]>0: a+=V[i]-C[i] print(a)
p03060
import sys from bisect import * from collections import * from copy import deepcopy from datetime import * from heapq import * from itertools import * from math import * from operator import * from pprint import * sys.setrecursionlimit(10**8) input = sys.stdin.readline def main(): """ main """ N = int(eval(input())) VS = list(map(int, input().split())) CS = list(map(int, input().split())) ans = 0 for bit in range(2**N): tmp = 0 for i in range(N): if bit & 1<<i == 0: continue tmp += VS[i] - CS[i] ans = max(ans, tmp) print(ans) if __name__ == '__main__': main()
import sys from bisect import * from collections import * from copy import deepcopy from datetime import * from heapq import * from itertools import * from math import * from operator import * from pprint import * sys.setrecursionlimit(10**8) input = sys.stdin.readline def main(): """ main """ N = int(eval(input())) VS = list(map(int, input().split())) CS = list(map(int, input().split())) ans = 0 for i in range(N): if VS[i] - CS[i] > 0: ans += VS[i] - CS[i] print(ans) if __name__ == '__main__': main()
p03060
from collections import Counter from functools import reduce import bisect import fractions import math import statistics import sys import time sys.setrecursionlimit(10**7) INF = 10 ** 18 MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] # LIST INT def LF(): return [float(x) for x in sys.stdin.readline().split()] # LIST FLOAT def LS(): return sys.stdin.readline().split() # LIST STRING def MI(): return map(int, sys.stdin.readline().split()) # MAP INT def II(): return int(sys.stdin.readline()) # INPUT INT def IS(): return input() # INPUT STRING def P(x): return print(x) def C(x): return Counter(x) def GCD_LIST(numbers): # Greatest Common Divisor return reduce(fractions.gcd, numbers) def LCM_LIST(numbers): # Least Common Multiple return reduce(LCM, numbers) def LCM(m, n): return (m * n // fractions.gcd(m, n)) n = II() v = LI() c = LI() y = 0 maxi = -1000000000000 for i in range(2 ** n): total = 0 y =0 for j in range(n): if ((i >> j) & 1): total += v[j] y += c[j] maxi = max(maxi, total-y) print(maxi)
from collections import Counter from functools import reduce import bisect import fractions import math import statistics import sys import time sys.setrecursionlimit(10**7) INF = 10 ** 18 MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] # LIST INT def LF(): return [float(x) for x in sys.stdin.readline().split()] # LIST FLOAT def LS(): return sys.stdin.readline().split() # LIST STRING def MI(): return map(int, sys.stdin.readline().split()) # MAP INT def II(): return int(sys.stdin.readline()) # INPUT INT def IS(): return input() # INPUT STRING def P(x): return print(x) def C(x): return Counter(x) def GCD_LIST(numbers): # Greatest Common Divisor return reduce(fractions.gcd, numbers) def LCM_LIST(numbers): # Least Common Multiple return reduce(LCM, numbers) def LCM(m, n): return (m * n // fractions.gcd(m, n)) n = II() v = LI() c = LI() xy = [v[i] - c[i] for i in range(n)] print(sum([ xy[i] for i in range(n) if xy[i] > 0]))
p03060
N = int(eval(input())) V = list(map(int,input().split())) C = list(map(int,input().split())) ans = 0 for i,j in zip(V,C): ans += max(0,i-j) print(ans)
N = int(eval(input())) V = list(map(int,input().split())) C = list(map(int,input().split())) ans = 0 for i in range(N): if V[i]-C[i]>0: ans += V[i]-C[i] print(ans)
p03060
def dfs(now,val,cost): if now == n: return val - cost else: return max(dfs(now+1,val+v[now],cost+c[now]),dfs(now+1,val,cost)) n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) print((dfs(0,0,0)))
# def dfs(now,val,cost): # if now == n: # return val - cost # else: # return max(dfs(now+1,val+v[now],cost+c[now]),dfs(now+1,val,cost)) n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) # print(dfs(0,0,0)) ans = 0 for i in range(n): tmp = v[i] - c[i] if tmp > 0: ans += tmp print(ans)
p03060
N = int(eval(input())) V = [int(x) for x in input().split()] C = [int(x) for x in input().split()] m = 0 for p in range(2**N): value = 0 for i in range(N): if ((p>>i) & 1): value = value + V[i] - C[i] if value > m: m = value print(m)
N = int(eval(input())) V = [int(x) for x in input().split()] C = [int(x) for x in input().split()] m = 0 for i in range(N): if (V[i]-C[i]) > 0: m = m + V[i]-C[i] print(m)
p03060
n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) max_z = 0 for i in range(2**n): #print("i:",i) x = 0 y = 0 for j in range(n): if i&(1<<j)!=0: #print('j:',j) x+=v[j] y+=c[j] z=x-y #print(z) max_z = max(max_z,z) print(max_z)
n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) z=0 for i in range(n): if v[i]>c[i]: z+=v[i]-c[i] print(z)
p03060
#!/usr/bin/env python3 n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) x = 0 y = 0 for i in range(n): if v[i] >= c[i]: x += v[i] y += c[i] print((x - y))
#!/usr/bin/env python3 n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) ans = 0 for i in range(n): if v[i] >= c[i]: ans += v[i] - c[i] print(ans)
p03060
N=int(eval(input())) V=list(map(int,input().split())) C=list(map(int,input().split())) from itertools import combinations List=[] for i in range(N): List.append(i) ans=[] for i in range(1,N+1): for j in list(combinations(List,i)): tmp=0 for k in j: tmp+=V[k]-C[k] if tmp<0: tmp=0 ans.append(tmp) print((max(ans)))
N=int(eval(input())) V=list(map(int,input().split())) C=list(map(int,input().split())) ans=0 for i in range(N): if V[i]>=C[i]: ans+=V[i]-C[i] print(ans)
p03060
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) lst = [] for i in range(N): if V[i] > C[i]: lst.append(V[i] - C[i]) N = len(lst) high_score = 0 if N > 0: for i in range(2 ** N): a = list(str(bin(i))[2:]) for k in range(N - len(a)): a.insert(0, "0") b = list(map(int, a)) score = 0 for j in range(len(b)): score += lst[j] * b[j] if high_score < score: high_score = score print(high_score)
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) lst = [] for i in range(N): if V[i] > C[i]: lst.append(V[i] - C[i]) print((sum(lst)))
p03060
def main(): N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) arr = [] ans = [] for i in range(N): arr.append(V[i]-C[i]) for j in range(1 << N): output = [] for k in range(N): if ((j >> k) & 1) == 1: output.append(arr[k]) ans.append(sum(output)) if max(ans) < 0: print((0)) return print((max(ans))) main()
def main(): N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) ans = 0 for i in range(N): ans += max(V[i]-C[i], 0) print(ans) if __name__ == '__main__': main()
p03060
# -*- coding: utf-8 -*- n = int(eval(input())) vs = list(map(int, input().split())) cs = list(map(int, input().split())) value = 0 for d in [vs[i] - cs[i] for i in range(n)]: if d > 0: value = value + d print(value)
# -*- coding: utf-8 -*- n = int(eval(input())) vs = list(map(int, input().split())) cs = list(map(int, input().split())) print((sum(d for d in [vs[i] - cs[i] for i in range(n)] if d > 0)))
p03060
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) ans = 0 for i in range(1 << n): value = 0 cost = 0 for j in range(n): if i >> j & 1: value += v[j] cost += c[j] ans = max(ans, value - cost) print(ans)
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) ans = 0 for i in range(n): if v[i] > c[i]: ans += v[i] - c[i] print(ans)
p03060
N = int(eval(input())) V = list(map(int,input().split())) C = list(map(int,input().split())) ans = 0 for i in range(2**N): X=0 Y=0 for j in range(N): if((i>>j)&1): X+=V[j] Y+=C[j] if X-Y>ans: ans = X-Y print(ans)
N = int(eval(input())) V = list(map(int,input().split())) C = list(map(int,input().split())) V_C = [V[i]-C[i] for i in range(N)] ans = 0 for i in range(N): if V_C[i]>0: ans += V_C[i] print(ans)
p03060
import itertools import math import fractions import functools import copy n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) sum = 0 for i in range(n): if v[i] > c[i]: sum += v[i] - c[i] print(sum)
import math def main(): n = int(eval(input())) # a, b, t = map(int, input().split()) # h = list(map(int, input().split())) # s = input() # h = [int(input()) for _ in rane(n)] v = list(map(int, input().split())) c = list(map(int, input().split())) sub = [v[i]-c[i] for i in range(n)] ans = 0 for num in sub: if num >0: ans +=num print(ans) if __name__ == '__main__': main()
p03060
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) ans=-10*18 for i in range(1<<n): mask=[(i>>j)&1 for j in range(n)] X=0 Y=0 for k, m in enumerate(mask): if m==1: X+=v[k] Y+=c[k] ans=max(ans, X-Y) print(ans)
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) ans=0 for x,y in zip(v,c): ans+=max(x-y, 0) print(ans)
p03060
from itertools import product as p N = int(eval(input())) *V, = list(map(int, input().split())) *C, = list(map(int, input().split())) l = [(i, j) for i,j in zip(V, C)] ans = -10**12 for i in p(list(range(2)), repeat=N): X, Y = 0, 0 for j, k in enumerate(i): if k==1: X += V[j] Y += C[j] ans = max(ans, X-Y) print(ans)
from itertools import product as p N = int(eval(input())) *V, = list(map(int, input().split())) *C, = list(map(int, input().split())) ans = -10**12 for i in p(list(range(2)), repeat=N): X, Y = 0, 0 for j, k in enumerate(i): if k==1: X += V[j] Y += C[j] ans = max(ans, X-Y) print(ans)
p03060
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) gain = [0]*n for i in range(n): if v[i]-c[i] > 0: gain[i] = v[i]-c[i] print((sum(gain)))
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) surplus = [v - c for v, c in zip(v, c)] surplus = [v for v in surplus if v > 0] print((sum(surplus)))
p03060
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) difer = [v - c for v, c in zip(V, C)] ans = 0 for i in range(len(difer)): if difer[i] >= 0: ans += difer[i] print(ans)
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) ans = 0 for v, c in zip(V, C): if v-c >= 0: ans += (v-c) print(ans)
p03060
# coding: utf-8 from itertools import combinations, chain N = int(eval(input())) values = list(map(int, input().split())) costs = list(map(int, input().split())) sales = [v - c for v, c in zip(values, costs)] print((max(chain.from_iterable(list(map(sum, combinations(sales, i))) for i in range(0, N+1)))))
n = int(input().strip()) values = list(map(int, input().split())) costs = list(map(int, input().split())) sales = [v - c for v, c in zip(values, costs) if v > c] print((sum(sales)))
p03060
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] def dp2(ini, i, j): return [[ini]*i for _ in range(j)] #import bisect #bisect.bisect_left(B, a) #from collections import defaultdict #d = defaultdict(int) d[key] += value #from collections import Counter # a = Counter(A).most_common() #from itertools import accumulate #list(accumulate(A)) N = ii() V = li() C = li() B = 2**N ans = 0 for i in range(B): wa = 0 for j in range(N): if i & 1 << j: wa += V[j] - C[j] ans = max(wa, ans) print(ans)
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] def dp2(ini, i, j): return [[ini]*i for _ in range(j)] #import bisect #bisect.bisect_left(B, a) #from collections import defaultdict #d = defaultdict(int) d[key] += value #from collections import Counter # a = Counter(A).most_common() #from itertools import accumulate #list(accumulate(A)) N = ii() V = li() C = li() sa = [V[i] - C[i] for i in range(N) if V[i] - C[i] > 0] print((sum(sa)))
p03060
n=int(eval(input())) v=list(map(int, input().split())) c=list(map(int, input().split())) ans=0 for _v,_c in zip(v,c): if _v < _c: continue ans+=_v-_c print(ans)
n = int(eval(input())) *v, = list(map(int, input().split())) *c, = list(map(int, input().split())) ans = 0 for _v, _c in zip(v, c): vc = _v - _c if 0 <= vc: ans += vc print(ans)
p03060
n=int(eval(input())) v=[int(i) for i in input().split()] c=[int(i) for i in input().split()] dif=[] for i in range(n): if v[i]>c[i]: dif.append(v[i]-c[i]) ans=0 for i in range(1 << len(dif)): sum=0 for j in range(len(dif)): if ((i>>j)&1)==1: sum += dif[j] ans = max(ans, sum) print(ans)
n=int(eval(input())) v=[int(i) for i in input().split()] c=[int(i) for i in input().split()] dif=[] for i in range(n): if v[i]>c[i]: dif.append(v[i]-c[i]) print((sum(dif)))
p03060
from functools import reduce from operator import add n=int(eval(input())) v=[int(i) for i in input().split()] c=[int(i) for i in input().split()] l=[v[i]-c[i] for i in range(n) if v[i]>c[i]] print((reduce(add,l) if l else 0))
n=int(eval(input())) v=[int(i) for i in input().split()] c=[int(i) for i in input().split()] sum=0 for i in range(n): if v[i]>c[i]: sum+=v[i]-c[i] print(sum)
p03060
n = int(eval(input())) v = input().split() c = input().split() answer = 0 for i in range(1 << n): tmp = 0 for j in range(n): if i & (1 << j): tmp += int(v[j]) - int(c[j]) if answer < tmp: answer = tmp print(answer)
n = int(eval(input())) v = input().split() c = input().split() vc = [] for i in range(n): vc.append(int(v[i]) - int(c[i])) answer = 0 for i in vc: if i > 0: answer += i print(answer)
p03060
import itertools as it N = int(eval(input())) V = [int(i) for i in input().split()] C = [int(i) for i in input().split()] ans = 0 for ith_conf in it.product(list(range(2)), repeat=N): dif = 0 for j_jewel in range(N): if ith_conf[j_jewel] == 1: dif += V[j_jewel] - C[j_jewel] ans = max(ans, dif) print(ans)
N = int(eval(input())) V = [int(i) for i in input().split()] C = [int(i) for i in input().split()] ans = 0 for i in range(N): if V[i] > C[i]: ans += V[i] - C[i] print(ans)
p03060
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) ans = 0 for i in range(2 ** n): k = 0 m = 0 for j in range(n): if (i >> j) & 1: k += v[j] m += c[j] ans = max(ans, k - m) print(ans)
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) ans = 0 for i in range(n): if v[i] > c[i]: ans += v[i] - c[i] print(ans)
p03060
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) ans = 0 for i in range(N): tmp = V[i] - C[i] if tmp > 0: ans += V[i] - C[i] print(ans)
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) ans = 0 for i in range(N): tmp = V[i] - C[i] if tmp > 0: ans += tmp print(ans)
p03060
n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) ans = 0 def chr(a,l): # print(a,l) if a == n: x = 0 y = 0 for i in range(n): x += v[i]*l[i] y += c[i]*l[i] return(x-y) else: l[a] = 1 ans1 = chr(a+1,l) l[a] = 0 ans2 = chr(a+1,l) return(max(ans1,ans2)) l = [0 for i in range(n)] print((chr(0,l)))
n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) ans = [] def chr(a,l,r): global ans if a == n: ans.append(r-l) else: chr(a+1,l+c[a],r+v[a]) chr(a+1,l,r) chr(0,0,0) print((max(ans)))
p03060
from itertools import combinations N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) maxv = 0 for i in range(1, N+1): for t in list(combinations(list(range(N)), i)): X = sum(V[k] for k in t) Y = sum(C[k] for k in t) maxv = max(maxv, X-Y) print(maxv)
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) maxv = 0 for v, c in zip(V, C): if v > c: maxv += (v-c) print(maxv)
p03060
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) maxxy = -10**9 for i in range(2**n): s = '0'*n + format(i, 'b') sl = list(s) #print(s) xy = 0 for j in range(n): a = sl.pop(-1) if a == '1': xy += v[j] xy -= c[j] if xy > maxxy: maxxy = xy #print(s) print(maxxy)
import itertools as itr n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) maxxy = -10**9 for i2 in itr.product((0,1), repeat = n): xy = 0 for j in range(n): if i2[j] == 1: xy += v[j] xy -= c[j] if xy > maxxy: maxxy = xy #print(s) print(maxxy)
p03060
n = int(eval(input())) v = list(map(int, input().split(' '))) c = list(map(int, input().split(' '))) ans = 0 for bit in range(1 << n): tmp = 0 for i in range(n): if bit >> i & 1: tmp += v[i] - c[i] ans = max(ans, tmp) print(ans)
n = int(eval(input())) v = list(map(int, input().split(' '))) c = list(map(int, input().split(' '))) ans = 0 for i in range(n): ans += max(0, v[i] - c[i]) print(ans)
p03060