結果

問題 No.4 おもりと天秤
ユーザー けむけむけむけむ
提出日時 2021-10-24 13:20:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 548 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 817,904 KB
最終ジャッジ日時 2024-04-09 23:58:46
合計ジャッジ時間 3,640 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,752 KB
testcase_01 AC 27 ms
10,880 KB
testcase_02 AC 38 ms
12,288 KB
testcase_03 AC 28 ms
10,752 KB
testcase_04 AC 32 ms
11,776 KB
testcase_05 MLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations 

def omori(N, W):
    SUM = 0
    for i in range(N):
        SUM += W[i]
    if SUM % 2 != 0:
        return 'impossible'
    half = SUM // 2
    for j in range(1, N//2+1):
        li = list(combinations(W, j))
        for k in range(len(li)):
            sum_k = sum(li[k])
            if sum_k == half:
                return 'possible'
    return 'impossible'
    
    
def main():
    N = int(input())
    W = list(map(int, input().split()))
    print(omori(N, W))
    

if __name__ == '__main__':
    main()
0