結果

問題 No.1279 Array Battle
ユーザー mesame3993
提出日時 2021-11-18 19:08:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 157 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 81,748 KB
実行使用メモリ 75,232 KB
最終ジャッジ日時 2024-12-26 18:47:43
合計ジャッジ時間 2,846 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
  from sys import stdin
  from itertools import permutations
  readline=stdin.readline
  n = int(readline())
  A = list(map(int, readline().split()))
  B = list(map(int, readline().split()))
  ans = 0
  L = [x for x in range(n)]
  for i in permutations(L):
    tmp = 0
    k = 0
    for j in i:
      tmp += max(A[j]-B[k], 0)
      k += 1
    ans = max(ans, tmp)
  cnt = 0
  for i in permutations(L):
    tmp = 0
    k = 0
    for j in i:
      tmp += max(A[j]-B[k], 0)
      k += 1
    if tmp == ans:
      cnt += 1
  print(cnt)
main()
0