GastonFontenla

Timus: 1796 - Amusement Park

Jun 5th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int k, a[6], b[6] = {10, 50, 100, 500, 1000, 5000};
  9.     for(int i=0; i<6; i++)
  10.         cin >> a[i];
  11.     cin >> k;
  12.  
  13.     ///Saber la máxima cantidad que puede comprar
  14.  
  15.     long long tiene = 0;
  16.  
  17.     for(int i=0; i<6; i++)
  18.         tiene += a[i]*b[i];
  19.  
  20.     int masChico = 99999;
  21.  
  22.     for(int i=0; i<6; i++)
  23.         if(a[i])
  24.             masChico = min(masChico, b[i]);
  25.  
  26.     long long minimo = tiene - masChico;
  27.  
  28.     vector <int> r;
  29.  
  30.     for(int i=tiene/k; i*k > minimo; i--)
  31.         r.push_back(i);
  32.  
  33.     cout << r.size() << endl;
  34.     for(int i=r.size()-1; i>=0; i--)
  35.         cout << r[i] << " ";
  36.  
  37.  
  38.     return 0;
  39. }
Add Comment
Please, Sign In to add comment