結果
問題 |
No.733 分身並列コーディング
|
ユーザー |
![]() |
提出日時 | 2025-06-12 20:47:16 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 78 ms / 1,500 ms |
コード長 | 958 bytes |
コンパイル時間 | 203 ms |
コンパイル使用メモリ | 82,036 KB |
実行使用メモリ | 76,160 KB |
最終ジャッジ日時 | 2025-06-12 20:48:24 |
合計ジャッジ時間 | 3,775 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
import sys def can_assign(k, tasks, T): tasks.sort(reverse=True) n = len(tasks) times = [0] * k def backtrack(index): if index == n: return True current_t = tasks[index] for i in range(k): if i > 0 and times[i] == times[i-1]: continue if times[i] + current_t <= T: times[i] += current_t if backtrack(index + 1): return True times[i] -= current_t if times[i] == 0: break return False return backtrack(0) 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) min_k = (sum_t + T - 1) // T for k in range(min_k, N + 1): if can_assign(k, t, T): print(k) return print(N) if __name__ == "__main__": main()