Advertisement
mickypinata

SMMR-T135: Stores

Mar 26th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int nb;
  5. int first[20];
  6. int second[20];
  7. double mn, ss, sf, f, s;
  8.  
  9. void ChooseBook(int n){
  10.     if(n > nb){
  11.         mn = min(mn, (sf - (f / 100) * sf) + (ss - (s / 100) * ss));
  12.         return;
  13.     } else {
  14.         ++f;
  15.         sf += first[n];
  16.         ChooseBook(n + 1);
  17.         --f;
  18.         sf -= first[n];
  19.         ++s;
  20.         ss += second[n];
  21.         ChooseBook(n + 1);
  22.         --s;
  23.         ss -= second[n];
  24.         return;
  25.     }
  26. }
  27.  
  28. int main(){
  29.  
  30.     scanf("%d", &nb);
  31.     for(int i = 1; i <= nb; ++i){
  32.         scanf("%d", &first[i]);
  33.     }
  34.     for(int i = 1; i <= nb; ++i){
  35.         scanf("%d", &second[i]);
  36.     }
  37.     mn = 2e9;
  38.     ChooseBook(1);
  39.     printf("%.2f", mn);
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement