Notice
Recent Posts
Recent Comments
- Today
- Total
01-26 01:17
Tags
- MST
- PS
- λ°±μ€
- λ€μ΅μ€νΈλΌ
- BFS
- OOP
- array
- spring
- database
- μλ°
- leetcode
- Graph
- μλ£κ΅¬μ‘°
- dp
- λ¬Έλ²
- μ‘Έμ μν
- μλ°μμ μ
- 벨λ§ν¬λ
- Algorithm
- λ°±μλ
- 그리λ
- CS
- tree
- μΈν΄
- java
- νλ‘κ·Έλλ¨Έμ€
- μμμ λ ¬
- λ°μ΄ν°λ² μ΄μ€
- ꡬν
- pytorch
Link
Partially Committed
[Summer/Winter Coding(~2018)] μμ° λ³Έλ¬Έ
728x90
λ°μν
SMALL
https://programmers.co.kr/learn/courses/30/lessons/12982
μ£Όμ΄μ§ μμ°μΌλ‘ μ΅λν λ§μ λΆμλ₯Ό μ§μν΄μΌνλ€.
μ¬μ€ κ°λ¨νλ€.
λΆμ λ³ μμ² μμ°μ λ΄μ λ°°μ΄μΈ d λ₯Ό μ€λ¦μ°¨μμΌλ‘ μ λ ¬ν λ€,
budget μμ λ°°μ΄ d μ μμλ₯Ό μ°¨λ‘λλ‘ λΊμ λ,
μΌλ§λ λ§μ μμλ₯Ό λΊ μ μλμ§λ₯Ό ꡬνλ©΄ λλ€.
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<int> d, int budget) {
int answer = 0;
sort(d.begin(), d.end());
for (auto& ele : d)
{
if (budget - ele < 0) break;
budget -= ele;
answer++;
}
return answer;
}
728x90
λ°μν
LIST
'π₯ Algorithm || λ¬Έμ νμ΄ > PS' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[νλ‘κ·Έλλ¨Έμ€] 2016λ (0) | 2022.07.04 |
---|---|
[μκ° μ½λ μ±λ¦°μ§ μμ¦1] λ κ° λ½μμ λνκΈ° (0) | 2022.07.04 |
[μκ° μ½λ μ±λ¦°μ§ μμ¦1] 3μ§λ² λ€μ§κΈ° (0) | 2022.07.04 |
[μκ° μ½λ μ±λ¦°μ§ μμ¦2] μ½μμ κ°μμ λ§μ (0) | 2022.07.04 |
[2019 KAKAO BLIND RECRUITMENT] μ€ν¨μ¨ (0) | 2022.07.04 |
Comments