| ps | |
|---|---|
| 링크 | acmicpc.net/… |
| 출처 | BOJ |
| 문제 번호 | 16975 |
| 문제명 | 수열과 쿼리 21 |
| 레벨 | 플래티넘 4 |
| 분류 |
구간 쿼리 |
| 시간복잡도 | O(n+mlogn) |
| 인풋사이즈 | n<=100,000, m<=100,000 |
| 사용한 언어 | Python 3.11 |
| 제출기록 | 43396KB / 432ms |
| 최고기록 | 632ms |
| 해결날짜 | 2023/01/17 |
| 태그 | |
"""Solution code for "BOJ 16975. 수열과 쿼리 21".
- Problem link: https://www.acmicpc.net/problem/16975
- Solution link: http://www.teferi.net/ps/problems/boj/16975
"""
import sys
from teflib import fenwicktree
def main():
N = int(sys.stdin.readline()) # pylint: disable=unused-variable
A = [int(x) for x in sys.stdin.readline().split()]
M = int(sys.stdin.readline())
fenwick = fenwicktree.FenwickTreeForRangeUpdatePointQuery(A)
for _ in range(M):
match sys.stdin.readline().split():
case ['1', i, j, k]:
fenwick.range_update(int(i) - 1, int(j), int(k))
case ['2', x]:
print(fenwick.get(int(x) - 1))
if __name__ == '__main__':
main()