[20250623] BOJ / P3 / System Call / 권혁준#382
Merged
ShinHeeEul merged 1 commit intomainfrom Jun 23, 2025
Merged
Conversation
Contributor
|
삼분탐색 ㄷㄷ |
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/15825
🧭 풀이 시간
100분
👀 체감 난이도
✏️ 문제 설명
크기가 각각 F[i]인 N개의 파일들이 있다.
하나의 파일을 읽을 때, 버퍼의 크기 K만큼 읽을 수 있고, 시간은 (T+K)만큼 걸린다.
모든 파일을 읽는 가장 짧은 시간과 그 때의 버퍼 크기를 구해보자.
🔍 풀이 방법
그냥 깡 수학 문제임
버퍼의 크기가 K일 때 파일들을 읽는 데 걸리는 시간은$\sum {{\lceil \dfrac{F[i]}{K} \rceil (T + K)}}$ 이다.$\lceil \dfrac{F[i]}{K} \rceil$ 값이 바뀌게 되는 K를 말한다.$\sqrt{F[i]}$ 이다.$\sqrt{F[i]}$ 를 넘어가면 잘 존재하지 않는다.
단순히 모든 K를 확인하면 시간 초과가 나고, 답이 될 수 있는 K만 적절히 골라 탐색해야 한다.
여기서 적절한 K란, 어떤 파일 F[i]에 대해
그리고 이 K의 개수는 대략
또, 적절한 K는 값이
각 K에 대해, 버퍼의 크기가 K-1에서 K가 되었을 때 모든 파일들의$\lceil \dfrac{F[i]}{K} \rceil$ 합이 얼마만큼 줄어드는지 기록하는 배열을 만든다.
이제 버퍼의 크기를 1부터 늘려가며 변동이 있을 때만 시간 계산을 해주면 된다.
⏳ 회고
처음에는 저 적절한 K가 파일 크기의 약수인 줄 알고 풀었다가 틀렸음
그 다음엔 아예 풀이를 갈아엎고, K값에 따른 전체 시간이 볼록성을 가질 거라 생각했다.
볼록성을 지닌다면 풀이가
삼분 탐색으로 좁혀지기 때문에 일단 그냥 구현해보고 제출했는데 틀렸다. 볼록성이 없다는 게 증명이 된 거다.또 풀이를 갈아엎고 처음에 냈던 풀이를 다듬어 보니까 맞았다.
너무 어려웠음