File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed
Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ #include < string>
2+ #include < vector>
3+ #include < algorithm>
4+ #include < queue>
5+ using namespace std ;
6+
7+ struct work_cmp { // top에 가장 높은 수가 가도록 정렬
8+ bool operator ()(int t, int u) {
9+ return t < u;
10+ }
11+ };
12+
13+ long long solution107 (int n, vector<int > works) {
14+ long long answer = 0 ;
15+ priority_queue <int , vector<int >, work_cmp > pq;
16+ for (auto i : works)
17+ pq.push (i);
18+
19+ for (int i = 0 ; i < n; i++) {
20+ int a = pq.top ();
21+ pq.pop ();
22+ if (a == 0 )
23+ pq.push (0 );
24+ else
25+ pq.push (a - 1 );
26+ }
27+
28+ while (!pq.empty ()) {
29+ answer += pq.top ()*pq.top ();
30+ pq.pop ();
31+ }
32+ return answer;
33+ }
Original file line number Diff line number Diff line change 112112 <ClCompile Include =" Lv3\Lv3_섬연결하기.cpp" />
113113 <ClCompile Include =" Lv3\Lv3_순위.cpp" />
114114 <ClCompile Include =" Lv3\Lv3_숫자게임.cpp" />
115+ <ClCompile Include =" Lv3\Lv3_야근지수.cpp" />
115116 <ClCompile Include =" Lv3\Lv3_여행경로.cpp" />
116117 <ClCompile Include =" Lv3\Lv3_예산.cpp" />
117118 <ClCompile Include =" Lv3\Lv3_이중우선순위큐.cpp" />
120121 <ClCompile Include =" Lv3\Lv3_정수삼각형.cpp" />
121122 <ClCompile Include =" Lv3\Lv3_줄서는방법.cpp" />
122123 <ClCompile Include =" Lv3\Lv3_짝지어제거하기.cpp" />
124+ <ClCompile Include =" Lv3\Lv3_최고의집합.cpp" />
123125 <ClCompile Include =" Lv3\Lv3_카카오프렌즈컬러링북.cpp" />
124126 <ClCompile Include =" Lv3\Lv3_캠핑.cpp" />
125127 <ClCompile Include =" Lv3\Lv3_타일장식물.cpp" />
Original file line number Diff line number Diff line change 342342 <ClCompile Include =" Lv3\Lv3_멀리뛰기.cpp" >
343343 <Filter >소스 파일</Filter >
344344 </ClCompile >
345+ <ClCompile Include =" Lv3\Lv3_야근지수.cpp" >
346+ <Filter >소스 파일</Filter >
347+ </ClCompile >
348+ <ClCompile Include =" Lv3\Lv3_최고의집합.cpp" >
349+ <Filter >소스 파일</Filter >
350+ </ClCompile >
345351 </ItemGroup >
346352</Project >
You can’t perform that action at this time.
0 commit comments