본문 바로가기
Coding Test/Programmers

[Programmers] (완전탐색) Lv 2. 피로도

by song.ift 2024. 10. 23.

https://school.programmers.co.kr/learn/courses/30/lessons/87946

 

프로그래머스

SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프

programmers.co.kr

 

 

cpp
닫기
#include <string> #include <vector> #include <algorithm> using namespace std; int solution(int k, vector<vector<int>> dungeons) { //24.10.22 int answer = 0; sort(dungeons.begin(), dungeons.end()); do { ​​​​​int nk = k; ​​​​​int ch = 0; ​​​​​for (auto it = dungeons.begin(); it != dungeons.end(); ++it) ​​​​​{ ​​​​​​​​​if (nk >= (*it)[0]) ​​​​​​​​​{ ​​​​​​​​​​​​​nk -= (*it)[1]; ​​​​​​​​​​​​​++ch; ​​​​​​​​​} ​​​​​} ​​​​​answer = max(answer, ch); ​} while (next_permutation(dungeons.begin(), dungeons.end())); return answer; }

GitHub : https://github.com/developeSHG/Algorithm-Baekjoon_Programmers/commit/a08816b0b8a991811b0f4d7438616e3b349c33e3

 

[level 2] Title: 피로도, Time: 0.81 ms, Memory: 4.21 MB -BaekjoonHub · developeSHG/Algorithm-Baekjoon_Programmers@a08816b

developeSHG committed Oct 23, 2024

github.com

 

 

댓글