Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include "vector"
- using namespace std;
- void SelectionSort(vector<int>& a){
- int size = a.size();
- for(int i = 0; i < size; i++){
- int min = i;
- for(int j = i+1; j < size; j++){
- if(a[j] < a[min]){
- min = j;
- }
- }
- int c = a[min];
- a[min] = a[i];
- a[i] = c;
- }
- }
- int main() {
- int N = 0;
- cin >> N;
- int S = 0;
- cin >> S;
- vector<int> coins;
- for(int i = 0; i < N; i++){
- int a = 0;
- cin >> a;
- coins.push_back(a);
- }
- SelectionSort(coins);
- for(int i = N-1; i >= 0; i--){
- int k = round(S/coins[i]);
- S = S-k*coins[i];
- cout << coins[i] << " - " << k << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement