2777 2023. 01. 23 21:58:08 kohumark Bolha a számegyenesen python3 Accepted 100/100 17ms 13436 KiB
#chatgpt
n = int(input())
s = input()

# initialize current position to 0
current_position = 0

# iterate through the string of jumps
for jump in s:
    # if the jump is to the left, decrease the current position by 1
    if jump == "L":
        current_position -= 1
    # if the jump is to the right, increase the current position by 1
    elif jump == "R":
        current_position += 1

# the number of jumps to return home is the absolute value of the current position
print(abs(current_position))

Subtask Sum Test Verdict Time Memory
subtask1 0/0
1 Accepted 17ms 11008 KiB
2 Accepted 17ms 11360 KiB
subtask2 15/15
3 Accepted 17ms 11448 KiB
4 Accepted 17ms 11564 KiB
5 Accepted 17ms 11544 KiB
6 Accepted 17ms 12196 KiB
subtask3 10/10
7 Accepted 17ms 12080 KiB
8 Accepted 17ms 12188 KiB
9 Accepted 17ms 11920 KiB
10 Accepted 17ms 12264 KiB
11 Accepted 17ms 12396 KiB
subtask4 75/75
12 Accepted 16ms 12380 KiB
13 Accepted 17ms 12416 KiB
14 Accepted 17ms 12780 KiB
15 Accepted 17ms 12724 KiB
16 Accepted 17ms 12612 KiB
17 Accepted 17ms 12952 KiB
18 Accepted 17ms 13232 KiB
19 Accepted 17ms 13180 KiB
20 Accepted 17ms 13264 KiB
21 Accepted 17ms 13436 KiB