We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3d50fbd commit 66ba6c4Copy full SHA for 66ba6c4
1 file changed
ing-eoking/더 맵게.cc
@@ -0,0 +1,21 @@
1
+#include <string>
2
+#include <vector>
3
+#include <set>
4
+
5
+using namespace std;
6
7
+int solution(vector<int> scoville, int K) {
8
+ int answer = 0;
9
+ multiset<int> s(scoville.begin(), scoville.end());
10
+ auto it = s.begin();
11
+ while(*s.begin() < K)
12
+ {
13
+ if(++s.begin() == s.end()) return -1;
14
+ int sum = *s.begin() + *++s.begin()*2;
15
+ s.erase(s.begin(), ++(++s.begin()));
16
+ s.insert(sum);
17
+ answer++;
18
+ }
19
20
+ return answer;
21
+}
0 commit comments