AtCoder Beginner Contest 078 Review of past questions

Time required

スクリーンショット 2020-03-24 19.45.03.png

Impressions

I couldn't submit a single question when I lay down on the floor and fell asleep because I didn't understand the C problem at the virtual console. What is the meaning of Virtual Console? I feel that it was a commandment that this would happen because I'm doing techto without thinking about working hard (although I feel it every time). After all, I didn't understand the C problem even after the contest. why. → I forgot how to solve the limit, and I couldn't tackle the probability sensuously ... The D problem is solved after solving the C problem while looking at the answer. → I couldn't thoroughly understand the basics of the game problem.

Problem A

It is easy to write using the ternary operator.

answerA.py


x,y=input().split()
print("=" if x==y else "<" if x<y else ">")

B problem

Check whether each number of people can sit in ascending order from x.

answerB.py


x,y,z=map(int,input().split())
for i in range(x,0,-1):
    if i*y+(i+1)*z<=x:
        print(i)
        break

C problem

$ X = 1900 \ times m + 100 \ times (nm) $, $ p = (1/2) ^, where x [ms] is the time required for one execution and p is the probability of being accurate in all cases. Obviously it will be m $. From here I would like to find the total time y [ms] that answers the question, but I tried to find the limit ** assuming that I ended up with k runs here **. However, I completely forgot how to find the limit and could not solve it (I wanted to do it like this article ...). If you do it like the Writer solution, you can solve it with a simple linear equation without using the limit. In other words, ** the time taken for the first submission is x and the submission fails 1-p, it takes y more **, so $ y = x + (1-p) \ times y $ And y = x / p is obtained. The rest is just to calculate this, so it looks like this: ✳︎ Also, it is clear that the expected value of how many times an event that succeeds with a probability p will succeed is 1 / p **, so it should be remembered.

answerC.py


n,m=map(int,input().split())
x=100*n+1800*m
p=2**(-m)
print(int(x/p))

D problem

I didn't understand at all when I thought about it, but when I saw the answer, it wasn't. Is it just an idiot who can't do his best to solve it if he follows the standard? ?? First of all, these problems are ** overwhelmingly advantageous ** (** the game is not symmetric **, so that's the case). What's even more noticeable is that either ** x or y always takes the last card **. I would like to think about these two things in mind. First, if the first attack is ** taking the last card on your first turn **, then the second attack cannot do anything, so it will be $ abs (a [-1] -w) $. Next, if the first attack ** does not take the last card in your first turn **, you can also take the second card and the final score is $ abs (a_k-a_n) $ (k = It becomes 1 ~ n-1). The best first move under this is to keep $ a_k $ as far as possible from $ a_n $. However, in the case of $ k \ ne n-1 $, ** it gives the second attack room to select $ a_k $ as close as possible to $ a_n $ **. By repeating this operation, $ abs (a_l-a_n) $ (l = 1 ~ n-1) is finally determined, and if this score is smaller than $ abs (a_l-a_ {n-1}) $, * * The first choice for the first move was wrong **. Furthermore, the same thing can be said for the second attack, and if the final score is greater than $ abs (a_l-a_ {n-1}) $, ** the choice when choosing the card in the second attack was wrong. **It will be. In other words, from this ** equilibrium state **, if the first card is not selected in the first turn, the final score will be $ abs (a_n-a_ {n-1}) $. I understand. From the above, you can choose the larger of $ abs (a [-1] -w) $ and $ abs (a_n-a_ {n-1}) $ for the first attack, and it will be as follows (also for the first attack) It is not possible to choose a higher score (as discussed above).

answerD.py


n,z,w=map(int,input().split())
a=list(map(int,input().split()))
if len(a)==1:
    print(abs(a[-1]-w))
else:
    print(max(abs(a[-1]-w),abs(a[-1]-a[-2])))

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 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
AtCoder Beginner Contest 120 Review of past questions