27772023-01-23 21:58:08kohumarkBolha a számegyenesenpython3Accepted 100/10017ms13436 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))

SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted17ms11008 KiB
2Accepted17ms11360 KiB
subtask215/15
3Accepted17ms11448 KiB
4Accepted17ms11564 KiB
5Accepted17ms11544 KiB
6Accepted17ms12196 KiB
subtask310/10
7Accepted17ms12080 KiB
8Accepted17ms12188 KiB
9Accepted17ms11920 KiB
10Accepted17ms12264 KiB
11Accepted17ms12396 KiB
subtask475/75
12Accepted16ms12380 KiB
13Accepted17ms12416 KiB
14Accepted17ms12780 KiB
15Accepted17ms12724 KiB
16Accepted17ms12612 KiB
17Accepted17ms12952 KiB
18Accepted17ms13232 KiB
19Accepted17ms13180 KiB
20Accepted17ms13264 KiB
21Accepted17ms13436 KiB