Artifact Content
Not logged in

Artifact 72b87e10d5e14a674667844e035f68505493d630


#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class Nisoku { public:
   double theMax(vector <double> cards) 
   {
      sort(cards.begin(), cards.end());

      double ans = 0.0;
      for(int i=0; 2*i<=cards.size(); ++i)
         ans = max(ans,
            accumulate(cards.begin()+2*i, cards.end(),
               inner_product( cards.begin(), cards.begin()+i,
                              cards.rend()-2*i,
                              1.0, multiplies<double>(), plus<double>() ),
               multiplies<double>()
            )
         );
      return ans;
   }
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const double& Expected, const double& Received) {
 bool ok = (abs(Expected - Received) < 1e-9);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END    verify_case(_, Nisoku().theMax(cards));}
int main(){

CASE(0)
   double cards_[] = {5, 8};
     vector <double> cards(cards_, cards_+sizeof(cards_)/sizeof(*cards_)); 
   double _ = 40.0; 
END
CASE(1)
   double cards_[] = {1.5, 1.8};
     vector <double> cards(cards_, cards_+sizeof(cards_)/sizeof(*cards_)); 
   double _ = 3.3; 
END
CASE(2)
   double cards_[] = {8.26, 7.54, 3.2567};
     vector <double> cards(cards_, cards_+sizeof(cards_)/sizeof(*cards_)); 
   double _ = 202.82857868; 
END
CASE(3)
   double cards_[] = {1.5, 1.7, 1.6, 1.5};
     vector <double> cards(cards_, cards_+sizeof(cards_)/sizeof(*cards_)); 
   double _ = 9.920000000000002; 
END
CASE(4)
   double cards_[] = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
10, 10, 10, 10, 10, 10, 10, 10, 10, 10};
     vector <double> cards(cards_, cards_+sizeof(cards_)/sizeof(*cards_)); 
   double _ = 1.0E50; 
END

}
// END CUT HERE