結果
問題 | No.177 制作進行の宮森あおいです! |
ユーザー | e-mon |
提出日時 | 2015-05-27 00:58:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 271 ms / 2,000 ms |
コード長 | 1,948 bytes |
コンパイル時間 | 782 ms |
コンパイル使用メモリ | 86,624 KB |
実行使用メモリ | 79,292 KB |
最終ジャッジ日時 | 2023-09-20 15:26:45 |
合計ジャッジ時間 | 3,480 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 80 ms
71,068 KB |
testcase_01 | AC | 84 ms
75,220 KB |
testcase_02 | AC | 75 ms
71,108 KB |
testcase_03 | AC | 100 ms
76,156 KB |
testcase_04 | AC | 105 ms
76,064 KB |
testcase_05 | AC | 126 ms
78,188 KB |
testcase_06 | AC | 187 ms
78,876 KB |
testcase_07 | AC | 82 ms
74,664 KB |
testcase_08 | AC | 112 ms
77,920 KB |
testcase_09 | AC | 271 ms
79,292 KB |
testcase_10 | AC | 262 ms
79,284 KB |
testcase_11 | AC | 246 ms
78,660 KB |
testcase_12 | AC | 200 ms
79,264 KB |
testcase_13 | AC | 75 ms
71,168 KB |
testcase_14 | AC | 74 ms
70,952 KB |
testcase_15 | AC | 77 ms
71,068 KB |
ソースコード
#!/usr/bin/env python # -*- coding: utf-8 -*- #(to, cap, rev) class ford_fulkerson: class Edge: def __init__(self, to, cap, rev): self.to = to self.cap = cap self.rev = rev def __init__(self,V): self.V = V self.size = [0 for i in range(V)] self.G = [[] for i in range(V)] def add_edge(self, _from, to, cap): self.size[_from] self.G[_from].append(self.Edge(to, cap, self.size[to])) self.G[to].append(self.Edge(_from, 0, self.size[_from])) self.size[_from] += 1 self.size[to] += 1 def dfs(self, v, t, f): if v == t: return f self.used[v] = True for i in range(len(self.G[v])): edge = self.G[v][i] if self.used[edge.to] is False and edge.cap > 0: d = self.dfs(edge.to, t, f if f < edge.cap else edge.cap) if d > 0: self.G[v][i].cap -= d self.G[edge.to][edge.rev].cap += d return d return 0 def max_flow(self, s, t): flow = 0 while True: self.used = [False for _ in range(self.V)] f = self.dfs(s, t, float('inf')) if f == 0: return flow flow += f W = int(input()) N = int(input()) J = list(map(int,input().split())) M = int(input()) C = list(map(int,input().split())) ff = ford_fulkerson(N+M+2) for i in range(1,N+1): ff.add_edge(0,i,J[i-1]) for i in range(N+1,N+M+1): ff.add_edge(i,N+M+1,C[i-(N+1)]) Q = list(map(int,input().split())) counter = 1 for j in range(1,N+1): if Q[0] == 0 or Q[counter] != j: ff.add_edge(j, i, 10**8) elif Q[0] != 0 and Q[counter] == j: ff.add_edge(j, i, 0) counter += 1 if counter < Q[0] else 0 if ff.max_flow(0,N+M+1) >= W: print('SHIROBAKO') else: print('BANSAKUTSUKITA')