結果

問題 No.110 しましまピラミッド
ユーザー tnodinotnodino
提出日時 2022-06-08 21:59:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 3,763 ms / 5,000 ms
コード長 952 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 10,208 KB
最終ジャッジ日時 2023-10-21 04:12:47
合計ジャッジ時間 22,682 ms
ジャッジサーバーID
(参考情報)
judge15 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,208 KB
testcase_01 AC 33 ms
10,208 KB
testcase_02 AC 30 ms
10,208 KB
testcase_03 AC 31 ms
10,208 KB
testcase_04 AC 31 ms
10,208 KB
testcase_05 AC 31 ms
10,208 KB
testcase_06 AC 33 ms
10,208 KB
testcase_07 AC 32 ms
10,208 KB
testcase_08 AC 32 ms
10,208 KB
testcase_09 AC 3,602 ms
10,208 KB
testcase_10 AC 33 ms
10,208 KB
testcase_11 AC 191 ms
10,208 KB
testcase_12 AC 32 ms
10,208 KB
testcase_13 AC 31 ms
10,208 KB
testcase_14 AC 33 ms
10,208 KB
testcase_15 AC 33 ms
10,208 KB
testcase_16 AC 32 ms
10,208 KB
testcase_17 AC 900 ms
10,208 KB
testcase_18 AC 30 ms
10,208 KB
testcase_19 AC 451 ms
10,208 KB
testcase_20 AC 30 ms
10,208 KB
testcase_21 AC 32 ms
10,208 KB
testcase_22 AC 33 ms
10,208 KB
testcase_23 AC 455 ms
10,208 KB
testcase_24 AC 3,607 ms
10,208 KB
testcase_25 AC 33 ms
10,208 KB
testcase_26 AC 34 ms
10,208 KB
testcase_27 AC 3,634 ms
10,208 KB
testcase_28 AC 3,763 ms
10,208 KB
testcase_29 AC 3,636 ms
10,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def check(s, t):
    for i in range(len(s)):
        if t[i] <= s[i]:
            return False
        if s[i] <= t[i+1]:
            return False
    return True

N = int(input())
W = list(map(int,input().split()))
M = int(input())
B = list(map(int,input().split()))
W.sort(reverse=True)
B.sort(reverse=True)
ans = 0
for bit_w in range(1<<N):
    for bit_b in range(1<<M):
        if abs(bin(bit_w).count('1') - bin(bit_b).count('1')) > 1:
            continue
        s = []
        t = []
        for i in range(N):
            if bit_w & (1<<i):
                s.append(W[i])
        for i in range(M):
            if bit_b & (1<<i):
                t.append(B[i])
        if len(s) == len(t):
            if check(s, [100] + t) or check(t, [100] + s):
                ans = max(ans, len(s)*2)
        else:
            if len(s) > len(t):
                s,t = t,s
            if check(s, t):
                ans = max(ans, len(s)*2+1)
print(ans)
0