| 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()