[PYTHON] AtCoder Beginner Contest 123 Review of past questions

Time required

スクリーンショット 2020-01-15 9.01.14.png

Problem A

Think by the difference between max and min

answerA.py


x=[int(input()) for i in range(5)]
k=int(input())
print("Yay!" if max(x)-min(x)<=k else ":(")

B problem

If the cooking time is only a multiple of 10, it doesn't matter in any order. If the cooking time is not a multiple of 10, ask for the one that is not a multiple of 10 and has the smallest remainder after dividing by 10. You can get the last dish delivered sooner.

answerB.py


import math
x=[int(input()) for i in range(5)]
y=[i%10 for i in x]
ans=0
for i in range(5):
    ans+=math.ceil(x[i]/10)*10
check=10
for i in range(5):
    if y[i]!=0:
        check=min(check,y[i])
if check==10:
    print(ans)
else:
    print(ans-(10-check))

C problem

I feel like it's the third time I've solved it ... It's easy because I know the answer once, but isn't it quite difficult at first glance? Obviously, the straightforward simulation shows that it is not in time, so if you experiment appropriately, you can see that the place where the number of people who can pass at one time is the smallest becomes a bottleneck and there is a blockage **. In addition, clogging other than the bottleneck can be combined into clogging at the bottleneck. In other words, you can ignore clogging in other parts by assuming that the bottleneck causes clogging by `math.ceil (n / min (x))-1```. If there is no bottleneck, it will arrive in 5 minutes in the shortest time, so the answer you are looking for is `5 + math.ceil (n / min (x))-1```.

answerC.py


import math
n=int(input())
x=[int(input()) for i in range(5)]
print(5+math.ceil(n/min(x))-1)

D problem

I didn't even know what went wrong in the RE and TLE on-parade. At first, I tried to solve with Writer solution 3 and stopped thinking of a simple implementation, and then tried to solve with 4 and the bug fix was quite good. I didn't go. This (Python ver, C ++ ver) is my ( It will be the answer (incorrect answer). I think that the pattern of repeated strays like this is due to ** I haven't been able to clarify what I want to do **. When I'm straying, I think I should reconsider with an awareness of ** clarifying the policy ** (but it's difficult because I'm impatient during the contest ...).

After several hours…

After a lot of consideration, I was finally able to AC in a way that I was satisfied with. There seem to be several solutions, but I will introduce two of them in Separate article.

Recommended Posts

AtCoder Beginner Contest 102 Review of past questions
AtCoder Beginner Contest 072 Review of past questions
AtCoder Beginner Contest 085 Review of past questions
AtCoder Beginner Contest 113 Review of past questions
AtCoder Beginner Contest 074 Review of past questions
AtCoder Beginner Contest 051 Review of past questions
AtCoder Beginner Contest 127 Review of past questions
AtCoder Beginner Contest 119 Review of past questions
AtCoder Beginner Contest 151 Review of past questions
AtCoder Beginner Contest 075 Review of past questions
AtCoder Beginner Contest 054 Review of past questions
AtCoder Beginner Contest 110 Review of past questions
AtCoder Beginner Contest 117 Review of past questions
AtCoder Beginner Contest 070 Review of past questions
AtCoder Beginner Contest 105 Review of past questions
AtCoder Beginner Contest 112 Review of past questions
AtCoder Beginner Contest 076 Review of past questions
AtCoder Beginner Contest 069 Review of past questions
AtCoder Beginner Contest 056 Review of past questions
AtCoder Beginner Contest 087 Review of past questions
AtCoder Beginner Contest 067 Review of past questions
AtCoder Beginner Contest 093 Review of past questions
AtCoder Beginner Contest 046 Review of past questions
AtCoder Beginner Contest 123 Review of past questions
AtCoder Beginner Contest 049 Review of past questions
AtCoder Beginner Contest 078 Review of past questions
AtCoder Beginner Contest 081 Review of past questions
AtCoder Beginner Contest 047 Review of past questions
AtCoder Beginner Contest 060 Review of past questions
AtCoder Beginner Contest 104 Review of past questions
AtCoder Beginner Contest 057 Review of past questions
AtCoder Beginner Contest 121 Review of past questions
AtCoder Beginner Contest 126 Review of past questions
AtCoder Beginner Contest 090 Review of past questions
AtCoder Beginner Contest 103 Review of past questions
AtCoder Beginner Contest 061 Review of past questions
AtCoder Beginner Contest 059 Review of past questions
AtCoder Beginner Contest 044 Review of past questions
AtCoder Beginner Contest 083 Review of past questions
AtCoder Beginner Contest 048 Review of past questions
AtCoder Beginner Contest 124 Review of past questions
AtCoder Beginner Contest 116 Review of past questions
AtCoder Beginner Contest 097 Review of past questions
AtCoder Beginner Contest 088 Review of past questions
AtCoder Beginner Contest 092 Review of past questions
AtCoder Beginner Contest 099 Review of past questions
AtCoder Beginner Contest 065 Review of past questions
AtCoder Beginner Contest 053 Review of past questions
AtCoder Beginner Contest 094 Review of past questions
AtCoder Beginner Contest 063 Review of past questions
AtCoder Beginner Contest 107 Review of past questions
AtCoder Beginner Contest 071 Review of past questions
AtCoder Beginner Contest 064 Review of past questions
AtCoder Beginner Contest 082 Review of past questions
AtCoder Beginner Contest 084 Review of past questions
AtCoder Beginner Contest 068 Review of past questions
AtCoder Beginner Contest 058 Review of past questions
AtCoder Beginner Contest 043 Review of past questions
AtCoder Beginner Contest 098 Review of past questions
AtCoder Beginner Contest 114 Review of past questions
AtCoder Beginner Contest 045 Review of past questions