結果
問題 | No.2329 Nafmo、イカサマをする |
ユーザー | masa_aa |
提出日時 | 2023-05-28 15:30:13 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,422 bytes |
コンパイル時間 | 381 ms |
コンパイル使用メモリ | 87,332 KB |
実行使用メモリ | 109,116 KB |
最終ジャッジ日時 | 2023-08-27 12:19:39 |
合計ジャッジ時間 | 5,880 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
71,340 KB |
testcase_01 | AC | 76 ms
75,308 KB |
testcase_02 | AC | 73 ms
71,104 KB |
testcase_03 | AC | 73 ms
71,200 KB |
testcase_04 | AC | 73 ms
71,184 KB |
testcase_05 | WA | - |
testcase_06 | AC | 75 ms
71,328 KB |
testcase_07 | AC | 73 ms
71,264 KB |
testcase_08 | AC | 91 ms
76,256 KB |
testcase_09 | WA | - |
testcase_10 | AC | 75 ms
71,336 KB |
testcase_11 | WA | - |
testcase_12 | AC | 76 ms
75,456 KB |
testcase_13 | WA | - |
testcase_14 | AC | 72 ms
71,408 KB |
testcase_15 | AC | 71 ms
71,412 KB |
testcase_16 | AC | 75 ms
75,844 KB |
testcase_17 | AC | 72 ms
71,292 KB |
testcase_18 | WA | - |
testcase_19 | AC | 91 ms
80,308 KB |
testcase_20 | AC | 81 ms
76,256 KB |
testcase_21 | AC | 77 ms
75,600 KB |
testcase_22 | AC | 83 ms
76,196 KB |
testcase_23 | AC | 73 ms
75,596 KB |
testcase_24 | AC | 70 ms
71,416 KB |
testcase_25 | WA | - |
testcase_26 | AC | 71 ms
71,300 KB |
testcase_27 | AC | 75 ms
75,608 KB |
testcase_28 | AC | 71 ms
71,304 KB |
testcase_29 | AC | 94 ms
77,232 KB |
testcase_30 | AC | 77 ms
75,640 KB |
testcase_31 | AC | 72 ms
71,460 KB |
testcase_32 | AC | 73 ms
75,512 KB |
testcase_33 | AC | 78 ms
75,536 KB |
testcase_34 | AC | 76 ms
75,356 KB |
testcase_35 | AC | 81 ms
75,924 KB |
testcase_36 | AC | 115 ms
79,924 KB |
testcase_37 | AC | 79 ms
76,208 KB |
testcase_38 | AC | 77 ms
75,604 KB |
testcase_39 | AC | 115 ms
83,540 KB |
testcase_40 | AC | 147 ms
97,968 KB |
testcase_41 | AC | 274 ms
109,116 KB |
testcase_42 | AC | 144 ms
98,128 KB |
ソースコード
from bisect import bisect_left, bisect_right # bisect_left(a, x): a[i] >= xとなるような最小のi. # 昇順ソートされたリストaに昇順を崩さずxを挿入できる位置s(0-index)を返す. # a = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19] # s = bisect_left(a,4), s = 2 n, m, k = map(int, input().split()) a = list(map(int, input().split())) + [0] if k == 1: ans = 0 for i in a: if i <= m and ans < i: ans = i print(ans) elif k == 2: b = [x + y for x in a for y in a if x + y <= m] print(max(b)) elif k == 3: b = [x + y for x in a for y in a for z in a if x + y + z <= m] print(max(b)) elif k == 4: b = [x + y + z for x in a for y in a for z in a if x + y + z <= m] b.sort() ans = 0 for i in a: k = bisect_left(b, m - i + 1) if k - 1 >= 0: ans = max(ans, b[k - 1] + i) print(ans) elif k == 5: b = [x + y + z for x in a for y in a for z in a if x + y + z <= m] c = [x + y for x in a for y in a if x + y <= m] b.sort() ans = 0 for i in c: k = bisect_left(b, m - i + 1) if k - 1 >= 0: ans = max(ans, b[k - 1] + i) print(ans) else: b = [x + y + z for x in a for y in a for z in a if x + y + z <= m] b.sort() ans = 0 for i in b: k = bisect_left(b, m - i + 1) if k - 1 >= 0: ans = max(ans, b[k - 1] + i) print(ans)