結果
| 問題 |
No.733 分身並列コーディング
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 15:49:44 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 70 ms / 1,500 ms |
| コード長 | 1,135 bytes |
| コンパイル時間 | 379 ms |
| コンパイル使用メモリ | 82,212 KB |
| 実行使用メモリ | 76,244 KB |
| 最終ジャッジ日時 | 2025-06-12 15:49:48 |
| 合計ジャッジ時間 | 3,452 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 46 |
ソースコード
import sys
def main():
T = int(sys.stdin.readline())
N = int(sys.stdin.readline())
t = [int(sys.stdin.readline()) for _ in range(N)]
sum_t = sum(t)
t_sorted = sorted(t, reverse=True)
for k in range(1, N + 1):
if sum_t > k * T:
continue
if any(x > T for x in t_sorted):
continue
sums = [0] * k
success = False
def backtrack(index):
nonlocal success
if success:
return
if index == len(t_sorted):
success = True
return
task = t_sorted[index]
for i in range(k):
if sums[i] + task > T:
continue
if i > 0 and sums[i] == sums[i - 1]:
continue
sums[i] += task
backtrack(index + 1)
if success:
return
sums[i] -= task
backtrack(0)
if success:
print(k)
return
print(N)
if __name__ == "__main__":
main()
gew1fw