제출 #1148080

#제출 시각아이디문제언어결과실행 시간메모리
1148080walkerCoin Collecting (JOI19_ho_t4)Pypy 3
0 / 100
150 ms48800 KiB
def calcular_costo_minimo(positions_initial, positions_target):
    costo_total = 0
    for pos_inicial, pos_objetivo in zip(positions_initial, positions_target):
        costo_total += abs(pos_inicial - pos_objetivo)
    return costo_total

def generar_lista_destino_x(N):
    destino_x = []
    for x in range(1, N + 1):
        destino_x.extend([x, x])
    return destino_x

def generar_lista_destino_y(N):
    destino_y = [1] * N + [2] * N
    return destino_y

def main():
    import sys
    input_data = sys.stdin.read().strip().split()
    if not input_data:
        return

    index = 0
    N = int(input_data[index])
    index += 1
    
    total_monedas = 2 * N
    lista_x = [] 
    lista_y = []  
    
    for _ in range(total_monedas):
        x = int(input_data[index])
        y = int(input_data[index + 1])
        index += 2
        lista_x.append(x)
        lista_y.append(y)
    
    lista_x.sort()
    lista_y.sort()
    
    destino_x = generar_lista_destino_x(N)
    destino_y = generar_lista_destino_y(N)
    
    costo_x = calcular_costo_minimo(lista_x, destino_x)
    costo_y = calcular_costo_minimo(lista_y, destino_y)
    
    costo_total = costo_x + costo_y
    
    sys.stdout.write(str(costo_total))

main()

컴파일 시 표준 출력 (stdout) 메시지

Compiling 'joi2019_ho_t4.py'...

=======
  adding: __main__.pyc (deflated 45%)

=======
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...