[Programmers] 저울

Time Lapse :43min 34sec

solution.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
//43:34
int solution(vector<int> weight) {
sort(weight.begin(),weight.end());
int answer = 0;
for(int i=0;i<weight.size();i++){
if(answer+1<weight[i]) break;
else answer+=weight[i];
}
return answer+1;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/30/PS/Programmers/scale/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.