Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int nb;
- int first[20];
- int second[20];
- double mn, ss, sf, f, s;
- void ChooseBook(int n){
- if(n > nb){
- mn = min(mn, (sf - (f / 100) * sf) + (ss - (s / 100) * ss));
- return;
- } else {
- ++f;
- sf += first[n];
- ChooseBook(n + 1);
- --f;
- sf -= first[n];
- ++s;
- ss += second[n];
- ChooseBook(n + 1);
- --s;
- ss -= second[n];
- return;
- }
- }
- int main(){
- scanf("%d", &nb);
- for(int i = 1; i <= nb; ++i){
- scanf("%d", &first[i]);
- }
- for(int i = 1; i <= nb; ++i){
- scanf("%d", &second[i]);
- }
- mn = 2e9;
- ChooseBook(1);
- printf("%.2f", mn);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement