디시인사이드 갤러리

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

갤러리 본문 영역

502. IPO

chromate00갤로그로 이동합니다. 2023.02.23 09:56:03
조회 31 추천 0 댓글 0
														
class Solution {
public:
    int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {
        int pt=0;
        priority_queue<int>Q;
        vector<pair<int,int>>V;
        int n=size(profits);
        for(int i=0;i<n;i++)V.emplace_back(-capital[i],profits[i]);
        sort(begin(V),end(V),greater<>{});
        for(int i=0;i<k;i++)
        {
            while(pt<n&&-V[pt].first<=w)Q.push(V[pt++].second);
            if(Q.empty())break;
            int mxp=Q.top();Q.pop();
            if(mxp<0)break;
            w+=mxp;
        }
        return w;
    }
};

루비 안 쓴 이유: 루비에 라이브러리로 우선순위 큐를 넣어줬다고는 하나 안 써봐서 쓸 줄을 모름


추천 비추천

0

고정닉 0

0

댓글 영역

전체 댓글 0
본문 보기

하단 갤러리 리스트 영역

왼쪽 컨텐츠 영역

갤러리 리스트 영역

갤러리 리스트
번호 제목 글쓴이 작성일 조회 추천
설문 2025년 가장 기억에 남는 인터넷 이슈는? 운영자 25/12/22 - -
212 1675. Minimize Deviation in Array chromate00갤로그로 이동합니다. 23.02.25 34 0
211 502. IPO 이벤트(1.226) 23.02.23 26 0
209 502. IPO 개발뉴비갤로그로 이동합니다. 23.02.23 32 0
502. IPO chromate00갤로그로 이동합니다. 23.02.23 31 0
207 1011. Capacity To Ship Packages Within D 이벤트(1.226) 23.02.22 17 0
206 1011. Capacity To Ship Packages Within D 개발뉴비갤로그로 이동합니다. 23.02.22 29 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 19 0
200 35. Search Insert Position 개발뉴비갤로그로 이동합니다. 23.02.20 28 0
199 35. Search Insert Position chromate00갤로그로 이동합니다. 23.02.20 28 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 19 0
194 226. Invert Binary Tree chromate00갤로그로 이동합니다. 23.02.18 15 0
193 226. Invert Binary Tree 개발뉴비갤로그로 이동합니다. 23.02.18 25 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 25 0
186 104. Maximum Depth of Binary Tree 개발뉴비갤로그로 이동합니다. 23.02.17 24 0
185 104. Maximum Depth of Binary Tree 이벤트(1.226) 23.02.16 17 0
183 104. Maximum Depth of Binary Tree chromate00갤로그로 이동합니다. 23.02.16 43 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 20 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 52 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 30 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 19 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 36 0
163 오늘의 데일리 (feat. ChatGPT) 개발뉴비갤로그로 이동합니다. 23.02.11 48 2
162 1162. As Far from Land as Possible chromate00갤로그로 이동합니다. 23.02.10 26 0
161 1162. As Far from Land as Possible 이벤트(1.226) 23.02.10 22 0
160 데일리 [1] ㅇㅇ(223.62) 23.02.10 42 0
159 오늘은 포기 이벤트(39.7) 23.02.09 32 1
158 2306. Naming a Company. chromate00갤로그로 이동합니다. 23.02.09 22 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