結果

問題 No.177 制作進行の宮森あおいです!
ユーザー e-mon
提出日時 2015-04-04 00:43:36
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-12-23 14:04:02
合計ジャッジ時間 1,216 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python
# -*- coding: utf-8 -*-

W = int(input())
N = int(input())
J = list(map(int,input().split()))
M = int(input())
C = list(map(int,input().split()))

flow = [[1 for i in range(N)] for j in range(M)]

for i in range(M):
    xs = list(map(int,input().split()))
    for j in xs[1:]:
        flow[i][j-1] = 0

for animator,a_v in sorted(enumerate(J),key=lambda x:-x[1]):
    directors = sorted([(C[i],i) for i in range(M) if flow[i][animator] == 1],key=lambda x:-x[0])
    for d_v,d in directors:
        volume = min(C[d],J[animator])
        C[d] -= volume
        J[animator] -= volume
        W -= volume
        if W <= 0:
            break
    if W <= 0:
        break
else:
    print('BANSAKUTSUKITA')
    quit()
print('SHIROBAKO')
0