-
Notifications
You must be signed in to change notification settings - Fork 0
[Week4] 전현수: 근손실, 톱니바퀴, 트리의 부모 찾기, 회의실 배정, 지름길 #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
soopeach
wants to merge
6
commits into
main
Choose a base branch
from
4week/hyunsoo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+421
−0
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Feat: 근손실 추가
- Loading branch information
commit abe70a39f2684cb1185f85756e8b36045d99bf23
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package `4week`.hyunsoo | ||
|
||
class 전현수_근손실{ | ||
/** | ||
* <문제> | ||
* [근손실](https://www.acmicpc.net/problem/18429) | ||
* | ||
* 하루가 지나면 중량이 K만큼 감소 | ||
* N개의 서로 다른 운동 키트를 가지고 있음. | ||
* 하루에 1개씩 키트를 사용. 사용하면 중량이 즉시 증가 | ||
* 운동 키트를 사용하면서 항상 중량이 500이상이 되도록 해야함. | ||
* | ||
* 아이디어 | ||
* - 완탐해서 모든 조합을 구하고 | ||
* - 각 조합들로 운동할 경우 500이상이 되는지를 판정하자! | ||
* | ||
*/ | ||
|
||
val exerciseKitList = mutableListOf<Int>() | ||
var possibleCaseCnt = 0 | ||
val exerciseCase = mutableListOf<Int>() | ||
val visited = BooleanArray(8) { false } | ||
|
||
fun solution() { | ||
|
||
val (exerciseCnt, downWeight) = readln().split(" ").map { it.toInt() } | ||
val exerciseData = readln().split(" ").map { it.toInt() } | ||
exerciseKitList.addAll(exerciseData) | ||
|
||
checkAllCases(0, exerciseCnt, downWeight) | ||
|
||
println(possibleCaseCnt) | ||
} | ||
|
||
fun checkAllCases(cnt: Int, depth: Int, downWeight: Int) { | ||
|
||
if (cnt == depth) { | ||
|
||
var curWeight = 500 | ||
exerciseCase.forEach { upWeight -> | ||
curWeight += upWeight - downWeight | ||
if (curWeight < 500) return | ||
} | ||
possibleCaseCnt++ | ||
return | ||
} | ||
for (index in 0 until exerciseKitList.size) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이부분 |
||
if (visited[index]) continue | ||
|
||
visited[index] = true | ||
exerciseCase.add(exerciseKitList[index]) | ||
checkAllCases(cnt + 1, depth, downWeight) | ||
visited[index] = false | ||
exerciseCase.removeAt(exerciseCase.lastIndex) | ||
} | ||
} | ||
} | ||
|
||
fun main(){ | ||
val myClass = 전현수_근손실() | ||
myClass.solution() | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런부분 lateinit 해주세요!!!!!!