Artifact Content
Not logged in

Artifact 4c5e2466526b5e9f2f31b41d54b76916779949f7


#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 BunnyComputer { public:
	int getMaximum(vector <int> preference, int k) 
	{
		int sum = 0;

		int N = preference.size();
		for(int s=0; s<=k && s<N; ++s)
		{
			vector<int> sub;
			for(int i=s; i<N; i+=1+k)
				sub.push_back( preference[i] );
			sum += accumulate(sub.begin(), sub.end(), 0);
			if( sub.size() % 2 == 1 )
			{
				vector<int> skip;
				for(int i=0; i<sub.size(); i+=2)
					skip.push_back( sub[i] );
				sum -= *min_element(skip.begin(), skip.end());
			}
		}

		return sum;
	}
};

// 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 int& Expected, const int& Received) {
 bool ok = (Expected == Received);
 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(_, BunnyComputer().getMaximum(preference, k));}
int main(){

CASE(0)
	int preference_[] = { 3, 1, 4, 1, 5, 9, 2, 6 };
	  vector <int> preference(preference_, preference_+sizeof(preference_)/sizeof(*preference_)); 
	int k = 2; 
	int _ = 28; 
END
CASE(1)
	int preference_[] = { 3, 1, 4, 1, 5, 9, 2, 6 };
	  vector <int> preference(preference_, preference_+sizeof(preference_)/sizeof(*preference_)); 
	int k = 1; 
	int _ = 31; 
END
CASE(2)
	int preference_[] = { 1, 2, 3, 4, 5, 6 };
	  vector <int> preference(preference_, preference_+sizeof(preference_)/sizeof(*preference_)); 
	int k = 3; 
	int _ = 14; 
END
CASE(3)
	int preference_[] = { 487, 2010 };
	  vector <int> preference(preference_, preference_+sizeof(preference_)/sizeof(*preference_)); 
	int k = 2; 
	int _ = 0; 
END
/*
CASE(4)
	int preference_[] = ;
	  vector <int> preference(preference_, preference_+sizeof(preference_)/sizeof(*preference_)); 
	int k = ; 
	int _ = ; 
END
CASE(5)
	int preference_[] = ;
	  vector <int> preference(preference_, preference_+sizeof(preference_)/sizeof(*preference_)); 
	int k = ; 
	int _ = ; 
END
*/
}
// END CUT HERE