ps | |
---|---|
링크 | acmicpc.net/… |
출처 | BOJ |
문제 번호 | 1321 |
문제명 | 군인 |
레벨 | 플래티넘 4 |
분류 |
구간 쿼리 |
시간복잡도 | O(n+mlogn) |
인풋사이즈 | n<=500,000, m<=10,000 |
사용한 언어 | Python |
제출기록 | 84628KB / 436ms |
최고기록 | 436ms |
해결날짜 | 2021/04/21 |
"""Solution code for "BOJ 1321. 군인".
- Problem link: https://www.acmicpc.net/problem/1321
- Solution link: http://www.teferi.net/ps/problems/boj/1321
"""
import sys
from teflib import fenwicktree
def main():
N = int(sys.stdin.readline()) # pylint: disable=unused-variable
soldiers = fenwicktree.OrderStatisticTree(
int(x) for x in sys.stdin.readline().split())
M = int(sys.stdin.readline())
for _ in range(M):
query = [int(x) for x in sys.stdin.readline().split()]
if query[0] == 1:
soldiers.add(query[1] - 1, query[2])
else:
print(soldiers.kth(query[1]) + 1)
if __name__ == '__main__':
main()