2777 2023. 01. 23 21:58:08 kohumark Bolha a számegyenesen python3 Elfogadva 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))

Részfeladat Összpont Teszt Verdikt Idő Memória
subtask1 0/0
1 Elfogadva 17ms 11008 KiB
2 Elfogadva 17ms 11360 KiB
subtask2 15/15
3 Elfogadva 17ms 11448 KiB
4 Elfogadva 17ms 11564 KiB
5 Elfogadva 17ms 11544 KiB
6 Elfogadva 17ms 12196 KiB
subtask3 10/10
7 Elfogadva 17ms 12080 KiB
8 Elfogadva 17ms 12188 KiB
9 Elfogadva 17ms 11920 KiB
10 Elfogadva 17ms 12264 KiB
11 Elfogadva 17ms 12396 KiB
subtask4 75/75
12 Elfogadva 16ms 12380 KiB
13 Elfogadva 17ms 12416 KiB
14 Elfogadva 17ms 12780 KiB
15 Elfogadva 17ms 12724 KiB
16 Elfogadva 17ms 12612 KiB
17 Elfogadva 17ms 12952 KiB
18 Elfogadva 17ms 13232 KiB
19 Elfogadva 17ms 13180 KiB
20 Elfogadva 17ms 13264 KiB
21 Elfogadva 17ms 13436 KiB