목차

결합

ps
링크acmicpc.net/…
출처BOJ
문제 번호24533
문제명결합
레벨실버 1
분류

애드 혹

시간복잡도O(n)
인풋사이즈n<3*10^5
사용한 언어Python 3.13
제출기록32412KB / 252ms
최고기록252ms
해결날짜2026/03/02

풀이

코드

"""Solution code for "BOJ 24533. 결합".

- Problem link: https://www.acmicpc.net/problem/24533
- Solution link: http://www.teferi.net/ps/problems/boj/24533

Tags: [ad hoc]
"""

import sys


def main():
    N = int(sys.stdin.readline())
    answer = 0
    c = d = 0
    for _ in range(N):
        a, b = [int(x) for x in sys.stdin.readline().split()]
        answer += a * d + b * c
        c, d = c + a, d + b
    print(answer)


if __name__ == '__main__':
    main()