Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 01371aa

Browse files
committed
[PG] 43238 입국심사_241017
1 parent 01f25ec commit 01371aa

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

‎Programmers/Level3/YJ_43238.java‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
public class YJ_43238 {
2+
public static void main(String[] args) {
3+
int n = 6;
4+
int[] times = {7, 10};
5+
System.out.println(binarySearch(n,times));
6+
}
7+
8+
static long binarySearch(int n, int[] times) {
9+
int length = times.length;
10+
long left = 0;
11+
long right = (long) times[length-1]*n;
12+
13+
while(left<right){
14+
long mid = (left+right)/2;
15+
16+
long count = 0;
17+
for(int time : times){
18+
count += mid/time;
19+
}
20+
21+
if(count>=n){
22+
right = mid;
23+
}else{
24+
left = mid+1;
25+
}
26+
}
27+
return right;
28+
}
29+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /