This time we will solve the B problem, which is more difficult than last time! !! Then, the problem is right away! !!
... what's this I think the difficulty level has been raised too much at once ... For the time being, I will draw a diagram and organize what I should ask for.
Indeed, looking at this figure, which seems to draw something that even this elementary school student is still good at, the answer to this question is the number of L's plus the first one. It was surprisingly easy! !! Then, I immediately wrote it in C ++ ...
Python "(´ ・ ω ・`) "
OT "What's wrong with Python !?"
Python "Don't I use it anymore? (´ ・ ω ・)"
OT "Because Python, I don't have the skills to write code with you ... I don't ....."
Python "Then I don't need a child? (´ ° ̥̥̥̥̥̥̥̥ω ° ̥̥̥̥̥̥̥̥ `)"
OT "Don't make such a sad face Paiso Oh oh oh oh"
...
...
... Yes, so this time I'll write the code in Python.
N, X = map(int, input().split())
L = list(map(int, input().split()))
distance = 0
bounds = 1
For the time being, declare all the variables to use! !!
N, X, L are described with reference to the comments received last time, and if you can clear even here, it should be somehow! !! bounds is the number of times the ball bounces, and the sentence with coordinate D0 is entered from the beginning. distance is the distance the ball has bounced.
for i in range(n):
distance += l[i]
if distance <= x:
bounds += 1
else:
break
print(bounds)
Make sure that the bounds are added until the distance exceeds X in this iterative statement. I managed to get AC! !!
This time I solved it earlier than last time, but the power of the previous comment was quite strong. Thank you for commenting m (_ _) m With this, the day to see Python's crying face will not come anymore ... I have an unreasonable feeling from Problem C ...
Thank you for reading.
Recommended Posts