일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 715. Range Module
- concurrency
- Python Code
- 운영체제
- 밴픽
- LeetCode
- shiba
- 43. Multiply Strings
- iterator
- Python
- Decorator
- Protocol
- 109. Convert Sorted List to Binary Search Tree
- Generator
- 시바견
- 315. Count of Smaller Numbers After Self
- t1
- kaggle
- 파이썬
- data science
- 프로그래머스
- Regular Expression
- 컴퓨터의 구조
- 30. Substring with Concatenation of All Words
- Convert Sorted List to Binary Search Tree
- Python Implementation
- Substring with Concatenation of All Words
- attribute
- Class
- DWG
Archives
- Today
- Total
Scribbling
[Programmers] 입국심사 본문
https://school.programmers.co.kr/learn/courses/30/lessons/43238
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
1. Python
def solution(n, times):
ret = max(times) * n
left, right = 0, ret
while left <= right:
mid = (left + right) // 2
cnt = 0
for time in times:
cnt += int(mid // time)
if cnt < n:
left = mid + 1
else:
ret = min(ret, mid)
right = mid - 1
return ret
2. C++
long long solution(int n, vector<int> times) {
long long ret = (long long) *max_element(times.begin(), times.end()) * n;
long long left = 0, right = ret;
while (left <= right) {
long long mid = (left + right) / 2;
long long cnt = 0;
for (long long time : times) {
cnt += mid / time;
}
if (cnt < n) {
left = mid + 1;
} else {
ret = min(ret, mid);
right = mid - 1;
}
}
return ret;
}
'Computer Science > Algorithms & Data Structures' 카테고리의 다른 글
[Programmers] 순위 (0) | 2024.06.28 |
---|---|
[Programmers] 가장 먼 노드 (0) | 2024.06.28 |
[Programmers] 징검다리 (0) | 2024.06.27 |
[Programmers] 여행경로 (0) | 2024.06.24 |
[Programmers] 아이템 줍기 (0) | 2024.06.21 |