結果

問題 No.1279 Array Battle
ユーザー Yosh
提出日時 2020-11-06 22:11:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 300 ms / 2,000 ms
コード長 2,179 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 156,596 KB
最終ジャッジ日時 2024-07-22 12:56:22
合計ジャッジ時間 5,320 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod = 1000000007


def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x, y: x * y % mod, range(n, n - r, -1), 1)
    denom = pow(reduce(lambda x, y: x * y % mod, range(1, r + 1), 1), mod - 2, mod)
    return numer * denom % mod


# def solve():
n = int(input().strip())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))

l_x_sum = []
l_p = []
for p in itertools.permutations([i for i in range(n)]):
    # eprint(p)
    x_sum = 0
    # eprint('temp ', end=': ')
    for (i, j) in enumerate(p):
        temp = max(a[j] - b[i], 0)
        # eprint(temp, end=" ")
        x_sum += temp
    # eprint()

    # eprint('p,x_sum ', end=':\n')
    # eprint(p, x_sum)
    l_x_sum.append(x_sum)
    l_p.append(p)

S = max(l_x_sum)
ans = 0
for i in range(len(l_x_sum)):
    if S == l_x_sum[i]:
        ans += 1
        # # eprint('l_p[i] ',end=':\n')
        # # eprint(l_p[i])
print(ans)
# print(l_x_sum)
0