結果
問題 | No.2329 Nafmo、イカサマをする |
ユーザー | masa_aa |
提出日時 | 2023-05-28 15:38:29 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,485 bytes |
コンパイル時間 | 1,496 ms |
コンパイル使用メモリ | 86,796 KB |
実行使用メモリ | 116,704 KB |
最終ジャッジ日時 | 2023-08-27 12:35:39 |
合計ジャッジ時間 | 5,422 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 76 ms
71,344 KB |
testcase_01 | AC | 77 ms
75,212 KB |
testcase_02 | AC | 76 ms
71,116 KB |
testcase_03 | AC | 75 ms
71,428 KB |
testcase_04 | AC | 79 ms
71,352 KB |
testcase_05 | WA | - |
testcase_06 | AC | 77 ms
71,252 KB |
testcase_07 | AC | 75 ms
71,316 KB |
testcase_08 | AC | 86 ms
76,076 KB |
testcase_09 | WA | - |
testcase_10 | AC | 74 ms
71,200 KB |
testcase_11 | WA | - |
testcase_12 | AC | 78 ms
75,776 KB |
testcase_13 | WA | - |
testcase_14 | AC | 73 ms
71,120 KB |
testcase_15 | AC | 74 ms
71,444 KB |
testcase_16 | AC | 78 ms
75,380 KB |
testcase_17 | AC | 73 ms
71,192 KB |
testcase_18 | WA | - |
testcase_19 | AC | 89 ms
80,460 KB |
testcase_20 | AC | 85 ms
75,760 KB |
testcase_21 | AC | 81 ms
75,496 KB |
testcase_22 | AC | 80 ms
75,664 KB |
testcase_23 | AC | 79 ms
75,348 KB |
testcase_24 | AC | 74 ms
71,332 KB |
testcase_25 | WA | - |
testcase_26 | AC | 73 ms
71,176 KB |
testcase_27 | AC | 76 ms
75,256 KB |
testcase_28 | AC | 74 ms
71,116 KB |
testcase_29 | AC | 90 ms
76,804 KB |
testcase_30 | AC | 79 ms
75,464 KB |
testcase_31 | AC | 76 ms
71,252 KB |
testcase_32 | AC | 77 ms
75,304 KB |
testcase_33 | AC | 77 ms
75,396 KB |
testcase_34 | AC | 77 ms
75,056 KB |
testcase_35 | AC | 83 ms
75,676 KB |
testcase_36 | AC | 98 ms
79,728 KB |
testcase_37 | AC | 82 ms
76,116 KB |
testcase_38 | AC | 80 ms
75,420 KB |
testcase_39 | AC | 110 ms
84,828 KB |
testcase_40 | AC | 123 ms
103,512 KB |
testcase_41 | AC | 160 ms
116,704 KB |
testcase_42 | AC | 122 ms
103,296 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 = list(set(b)) 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 = list(set(b)) 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 = list(set(b)) 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)