Submission #8853102


Source Code Expand

Copy
from copy import deepcopy
 
 
class Solver():
    def __init__(self, n, t):
        self.n = n
        self.t = t
 
    def depth_first_search(self,
                           niku_index: int,
                           yaki_index: int,
                           cumulative_times) -> int:
 
        cumulative_times[yaki_index] += self.t[niku_index]
        if niku_index == self.n - 1:
            return max(cumulative_times)
 
        return min(
            self.depth_first_search(niku_index + 1, 0, deepcopy(cumulative_times)),
            self.depth_first_search(niku_index + 1, 1, deepcopy(cumulative_times))
        )
 
    def solve(self) -> int:
        return min(
            self.depth_first_search(0, 0, [0, 0]),
            self.depth_first_search(0, 1, [0, 0])
        )
 
 
if __name__ == "__main__":
    n = int(input())
    t = []
    for _ in range(n):
        t.append(int(input()))
    s = Solver(n, t)
    print(s.solve())

Submission Info

Submission Time
Task A - 高橋君とお肉
User hagino3000
Language Python (3.4.3)
Score 100
Code Size 982 Byte
Status AC
Exec Time 88 ms
Memory 3696 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 19
Set Name Test Cases
Sample subtask0-sample-01.txt, subtask0-sample-02.txt, subtask0-sample-03.txt
All subtask0-sample-01.txt, subtask0-sample-02.txt, subtask0-sample-03.txt, subtask1-01.txt, subtask1-02.txt, subtask1-03.txt, subtask1-04.txt, subtask1-05.txt, subtask1-06.txt, subtask1-07.txt, subtask1-08.txt, subtask1-09.txt, subtask1-10.txt, subtask1-11.txt, subtask1-12.txt, subtask1-13.txt, subtask1-14.txt, subtask1-15.txt, subtask1-16.txt
Case Name Status Exec Time Memory
subtask0-sample-01.txt AC 88 ms 3696 KB
subtask0-sample-02.txt AC 22 ms 3440 KB
subtask0-sample-03.txt AC 22 ms 3440 KB
subtask1-01.txt AC 22 ms 3440 KB
subtask1-02.txt AC 22 ms 3440 KB
subtask1-03.txt AC 22 ms 3440 KB
subtask1-04.txt AC 22 ms 3440 KB
subtask1-05.txt AC 22 ms 3440 KB
subtask1-06.txt AC 22 ms 3440 KB
subtask1-07.txt AC 22 ms 3440 KB
subtask1-08.txt AC 22 ms 3440 KB
subtask1-09.txt AC 22 ms 3440 KB
subtask1-10.txt AC 22 ms 3440 KB
subtask1-11.txt AC 22 ms 3440 KB
subtask1-12.txt AC 22 ms 3440 KB
subtask1-13.txt AC 22 ms 3440 KB
subtask1-14.txt AC 22 ms 3440 KB
subtask1-15.txt AC 22 ms 3440 KB
subtask1-16.txt AC 22 ms 3440 KB