forked from ndb796/python-for-coding-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4.cpp
More file actions
28 lines (21 loc) · 498 Bytes
/
4.cpp
File metadata and controls
28 lines (21 loc) · 498 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> arr;
int main(void) {
cin >> n;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
arr.push_back(x);
}
sort(arr.begin(), arr.end());
int target = 1;
for (int i = 0; i < n; i++) {
// 만들 수 없는 금액을 찾았을 때 반복 종료
if (target < arr[i]) break;
target += arr[i];
}
// 만들 수 없는 금액 출력
cout << target << '\n';
}