Skip to content

Commit

Permalink
동전 0
Browse files Browse the repository at this point in the history
  • Loading branch information
yewon-yw authored Apr 14, 2022
1 parent 6746ff3 commit d62aa27
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions greedy_algorithm/11047.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <iostream>
using namespace std;
int arr[10];

int main() {
int N, K, count = 0;
int* pointer = arr;
cin >> N >> K;
for (int i = 0; i < N; i++) {
cin >> arr[i];
}
for (int i = 0; i < N; i++) {
if (arr[i] <= K) {
pointer = &arr[i];
}
}
while (K / *pointer >= 0) {
if (K / *pointer == 0) {
if (pointer != arr) pointer--;
else break;
continue;
}
K -= *pointer;
count++;
}
cout << count;
}

0 comments on commit d62aa27

Please sign in to comment.