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.
It is easy to write using the ternary operator.
answerA.py
x,y=input().split()
print("=" if x==y else "<" if x<y else ">")
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
$ 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))
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