結果
| 問題 |
No.733 分身並列コーディング
|
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 15:45:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 73 ms / 1,500 ms |
| コード長 | 1,086 bytes |
| コンパイル時間 | 486 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 76,288 KB |
| 最終ジャッジ日時 | 2025-06-12 15:46:02 |
| 合計ジャッジ時間 | 4,336 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 46 |
ソースコード
import sys
def can_assign(tasks, m, T):
tasks_sorted = sorted(tasks, reverse=True)
bins = [0] * m
def backtrack(index):
if index == len(tasks_sorted):
return True
current = tasks_sorted[index]
for i in range(m):
if bins[i] + current > T:
continue
if i > 0 and bins[i] == bins[i-1]:
continue
bins[i] += current
if backtrack(index + 1):
return True
bins[i] -= current
return False
return backtrack(0)
def main():
T = int(sys.stdin.readline())
N = int(sys.stdin.readline())
tasks = []
for _ in range(N):
tasks.append(int(sys.stdin.readline()))
S = sum(tasks)
k = sum(1 for t in tasks if t > T / 2)
m0 = max((S + T - 1) // T, k)
tasks_sorted = sorted(tasks, reverse=True)
for m in range(m0, N + 1):
if can_assign(tasks_sorted, m, T):
print(m)
return
print(N) # This line is theoretically unreachable
if __name__ == "__main__":
main()
gew1fw