結果
| 問題 | No.1279 Array Battle | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-02-18 20:29:44 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 434 ms / 2,000 ms | 
| コード長 | 433 bytes | 
| コンパイル時間 | 322 ms | 
| コンパイル使用メモリ | 82,176 KB | 
| 実行使用メモリ | 164,648 KB | 
| 最終ジャッジ日時 | 2024-09-15 01:37:40 | 
| 合計ジャッジ時間 | 4,065 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 | 
ソースコード
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
allpat=[]
todo=[[i] for i in range(n)]
while todo:
  v=todo.pop()
  if len(v)==n:
    allpat.append(v)
    continue
  for nv in range(n):
    if nv in v:continue
    todo.append(v+[nv])
mxv=0
ans=0
for pat in allpat:
  tmp=0
  for i in range(n):
    tmp+=max(0,a[pat[i]]-b[i])
  if tmp==mxv:
    ans+=1
  elif tmp>mxv:
    mxv=tmp
    ans=1
print(ans)
            
            
            
        