Friday, 24 July 2015

FASHION

Standard

Fashion Shows

Link to the question : FASHION 

HINT :

Simply just sort the array containing hotness level of men and women, then multiply the elements in the same index and keep on adding.

RECOMMENDED QUESTION :

Try solving this question   after getting an AC in this one.

SOURCE CODE :

  #include<iostream>
#include<new>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
     int *a,*b,n,s,i=0,t,j;
     cin>>t;
     while(t--)
     {
           cin>>s;
           i=0;
           a= new (nothrow)int[s];
           b= new (nothrow)int[s];
          for(j=0;j<s;j++)
                 cin>>a[j];
           sort(a,a+s);
             for(j=0;j<s;j++)
                  cin>>b[j];
              sort(b,b+s);
              for(j=0;j<s;j++)
              {
                  i= i+ a[j]*b[j];
              }
              cout<<i<<endl;
     }
 return 0;
}

0 comments:

Post a Comment