Submission #58565783


Source Code Expand

"""
<方針>
- `N==20` 程度なので,グループ `A` に属させるかどうかの全パターン `O(2^N)` を試しても `TLE` しない.
"""

# 入力
N = int(input())
K = list(map(int, input().split()))

# 最適値
ans = float("inf")
# Aに属するかどうかを全パターン試す.
for i in range(1<<N):
  # AとBのグループそれぞれの人数
  A = 0
  B = 0
  # Aに属するかBに属するかをみる
  for j in range(N):
    if(i>>j & 1):
      A += K[j]
    else:
      B += K[j]
  # AとBで人数が多かった方で更新する.
  ans = min(ans, max(A, B))
# 出力
print(ans)

Submission Info

Submission Time
Task C - Separated Lunch
User mattsunkun
Language Python (PyPy 3.10-v7.3.12)
Score 300
Code Size 640 Byte
Status AC
Exec Time 256 ms
Memory 82820 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 30
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt
Case Name Status Exec Time Memory
example_00.txt AC 56 ms 76492 KiB
example_01.txt AC 55 ms 76492 KiB
example_02.txt AC 55 ms 76252 KiB
hand_00.txt AC 245 ms 82732 KiB
hand_01.txt AC 256 ms 82596 KiB
hand_02.txt AC 253 ms 82424 KiB
hand_03.txt AC 56 ms 76360 KiB
hand_04.txt AC 244 ms 82348 KiB
hand_05.txt AC 243 ms 82756 KiB
random_00.txt AC 92 ms 81420 KiB
random_01.txt AC 90 ms 81560 KiB
random_02.txt AC 125 ms 82576 KiB
random_03.txt AC 127 ms 82704 KiB
random_04.txt AC 250 ms 82712 KiB
random_05.txt AC 123 ms 82544 KiB
random_06.txt AC 92 ms 81724 KiB
random_07.txt AC 125 ms 82352 KiB
random_08.txt AC 249 ms 82520 KiB
random_09.txt AC 92 ms 81448 KiB
random_10.txt AC 93 ms 81892 KiB
random_11.txt AC 124 ms 82520 KiB
random_12.txt AC 123 ms 82756 KiB
random_13.txt AC 244 ms 82476 KiB
random_14.txt AC 245 ms 82820 KiB
random_15.txt AC 253 ms 82708 KiB
random_16.txt AC 125 ms 82264 KiB
random_17.txt AC 126 ms 82460 KiB
random_18.txt AC 251 ms 82704 KiB
random_19.txt AC 127 ms 82808 KiB
random_20.txt AC 248 ms 82820 KiB