Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
https://www.acmicpc.net/problem/24547
🧭 풀이 시간
150분
👀 체감 난이도
✏️ 문제 설명
길이 N인 수열에 아래 쿼리를 Q번 처리해보자.

🔍 풀이 방법
1번 쿼리를 처리할 때 두 가지 경우로 나눈다.
$X$ 가 $\sqrt{100000}$ 보다 클 때는 (전체 합) - ([(k-1)X,kX)에 존재하는 A[i]의 개수) * (k-1)X 를 직접 구해도 $O(\sqrt{100000})$ 에 처리할 수 있다.
$X$ 가 $\sqrt{N}$ 이하일 때는 미리 전처리로 배열에 해당 값이 X일 때의 정답을 계산해둔다.$O(N\sqrt{100000})$ 이고, 값이 바뀔 때 이것도 같이 갱신해주면 $O(\sqrt{100000})$ 이 된다.
전처리 비용은
개수를 구할 때 세그먼트 트리가 필요해서 log 시간이 추가로 붙는다.
2,3번 쿼리도 위와 마찬가지로 쿼리당$O(\sqrt{100000} \times \log{100000})$ 에 처리할 수 있다.
⏳ 회고
상수를 열심히 깎았는데도 안 뚫린다.
내일 세그먼트 트리 대신 펜윅 트리를 적용해서 다시 해봐야겠다