디시인사이드 갤러리

마이너 갤러리 이슈박스, 최근방문 갤러리

갤러리 본문 영역

1011. Capacity To Ship Packages Within D

이벤트(1.226) 2023.02.22 20:40:35
조회 16 추천 0 댓글 0
														
class Solution {
public:
bool isOkay(int dayLimit, int capacity, vector<int>& weights) {
int sum = 1e9;
int day = 0;
for(int i = 0; i < weights.size(); i++) {
if(sum + weights[i] > capacity) {
day++;
sum = 0;
}
sum += weights[i];

if(day > dayLimit) {
return false;
}
}
return true;
}
int shipWithinDays(vector<int>& weights, int days) {
int lo = *max_element(weights.begin(), weights.end());
int hi = 2500*1e4;
int answer = hi;
while(lo <= hi) {
int mid = (lo + hi) / 2;
if(isOkay(days, mid, weights)) {
answer = mid;
hi = mid - 1 ;
}
else {
lo = mid + 1;
}
}
return answer;
}
};


추천 비추천

0

고정닉 0

0

댓글 영역

전체 댓글 0
본문 보기

하단 갤러리 리스트 영역

왼쪽 컨텐츠 영역

갤러리 리스트 영역

갤러리 리스트
번호 제목 글쓴이 작성일 조회 추천
설문 2025년 가장 기억에 남는 인터넷 이슈는? 운영자 25/12/22 - -
212 1675. Minimize Deviation in Array chromate00갤로그로 이동합니다. 23.02.25 32 0
211 502. IPO 이벤트(1.226) 23.02.23 26 0
209 502. IPO 개발뉴비갤로그로 이동합니다. 23.02.23 30 0
208 502. IPO chromate00갤로그로 이동합니다. 23.02.23 31 0
1011. Capacity To Ship Packages Within D 이벤트(1.226) 23.02.22 16 0
206 1011. Capacity To Ship Packages Within D 개발뉴비갤로그로 이동합니다. 23.02.22 28 0
205 1011. Capacity To Ship Packages Within D chromate00갤로그로 이동합니다. 23.02.22 20 0
204 540. Single Element in a Sorted Array 개발뉴비갤로그로 이동합니다. 23.02.21 26 0
203 540. Single Element in a Sorted Array 이벤트(1.226) 23.02.21 13 0
202 540. Single Element in a Sorted Array chromate00갤로그로 이동합니다. 23.02.21 21 0
201 35. Search Insert Position 이벤트(1.226) 23.02.21 18 0
200 35. Search Insert Position 개발뉴비갤로그로 이동합니다. 23.02.20 28 0
199 35. Search Insert Position chromate00갤로그로 이동합니다. 23.02.20 27 0
198 103. Binary Tree Zigzag Level Order Trav 개발뉴비갤로그로 이동합니다. 23.02.19 23 0
196 103. Binary Tree Zigzag Level Order Trav chromate00갤로그로 이동합니다. 23.02.19 20 0
195 103. Binary Tree Zigzag Level Order Trav 이벤트(1.226) 23.02.19 18 0
194 226. Invert Binary Tree chromate00갤로그로 이동합니다. 23.02.18 14 0
193 226. Invert Binary Tree 개발뉴비갤로그로 이동합니다. 23.02.18 24 0
191 226. Invert Binary Tree 이벤트(1.226) 23.02.18 22 0
189 783. Minimum Distance Between BST Nodes 개발뉴비갤로그로 이동합니다. 23.02.18 18 0
188 783. Minimum Distance Between BST Nodes chromate00갤로그로 이동합니다. 23.02.17 20 0
187 783. Minimum Distance Between BST Nodes 이벤트(1.226) 23.02.17 24 0
186 104. Maximum Depth of Binary Tree 개발뉴비갤로그로 이동합니다. 23.02.17 23 0
185 104. Maximum Depth of Binary Tree 이벤트(1.226) 23.02.16 16 0
183 104. Maximum Depth of Binary Tree chromate00갤로그로 이동합니다. 23.02.16 42 0
182 989. Add to Array-Form of Integer 이벤트(1.226) 23.02.15 17 0
181 989. Add to Array-Form of Integer chromate00갤로그로 이동합니다. 23.02.15 19 0
180 989. Add to Array-Form of Integer 개발뉴비갤로그로 이동합니다. 23.02.15 20 0
179 67. Add Binary 개발뉴비갤로그로 이동합니다. 23.02.14 30 0
178 67. Add Binary 이벤트(1.226) 23.02.14 21 0
177 67. Add Binary chromate00갤로그로 이동합니다. 23.02.14 31 0
176 1523. Count Odd Numbers in an Interval R chromate00갤로그로 이동합니다. 23.02.14 26 0
175 1523. Count Odd Numbers in an Interval R 이벤트(1.226) 23.02.13 17 0
174 1523. Count Odd Numbers in an Interval R 개발뉴비갤로그로 이동합니다. 23.02.13 28 0
173 2477. Minimum Fuel Cost to Report to the 개발뉴비갤로그로 이동합니다. 23.02.13 27 0
172 구현 문제 풀 때 꿀팁? 구현력 기르는 꿀팁? 있으신가요 ? [1] ㅇㅇ(180.67) 23.02.12 51 0
170 2477. Minimum Fuel Cost to Report to the 이벤트(1.226) 23.02.12 24 0
169 2477. Minimum Fuel Cost to Report to the [1] chromate00갤로그로 이동합니다. 23.02.12 29 0
168 2477. Minimum Fuel Cost to Report to the ㅇㅇ(218.234) 23.02.12 20 0
167 1129. Shortest Path with Alternating Col 이벤트(1.226) 23.02.12 18 0
166 1129. Shortest Path with Alternating Col [1] 개발뉴비갤로그로 이동합니다. 23.02.11 54 0
165 1129. Shortest Path with Alternating Col chromate00갤로그로 이동합니다. 23.02.11 35 0
163 오늘의 데일리 (feat. ChatGPT) 개발뉴비갤로그로 이동합니다. 23.02.11 47 2
162 1162. As Far from Land as Possible chromate00갤로그로 이동합니다. 23.02.10 25 0
161 1162. As Far from Land as Possible 이벤트(1.226) 23.02.10 22 0
160 데일리 [1] ㅇㅇ(223.62) 23.02.10 38 0
159 오늘은 포기 이벤트(39.7) 23.02.09 32 1
158 2306. Naming a Company. chromate00갤로그로 이동합니다. 23.02.09 21 0
157 2306. Naming a Company 개발뉴비갤로그로 이동합니다. 23.02.09 42 0
156 2306. Naming a company (설명X) [1] ㅇㅇ(218.234) 23.02.09 32 0
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

디시미디어

디시이슈

1/2