#include <iostream>
#include <vector>
using namespace std;
int solution( vector<int> days)
{
if(days.empty())
{
return 0;
}
if(days.size()==1)
{
return 2;
}
if(days.size()==2)
{
return 2*2;
}
if(days.size()==3)
{
return 2*3;
}
if(days.size()==4)
{
int tmpMin = 4 * 2;
if( days[0]+6>=days[3])
{
tmpMin = 7;
}
return tmpMin;
}
if(days.size()>=23 && days.size()<=30)
{
return 25;
}
if(days.size()>=31)
{
return 0;
}
// if vector.size is [5,22]
if(days.size()<=7)
{
if(days[0]+6>=days[days.size()-1])
{
return 7;
}
}
int minTmp = days.size() * 2;
for(int i =1; i < days.size(); ++i )
{
vector<int> tmpV1, tmpV2;
for(int j =0; j < i; ++j)
{
tmpV1.push_back(days[j]);
}
for(int j =i; j < days.size();++j)
{
tmpV2.push_back(days[j]);
}
int tmpSolution = solution(tmpV1) + solution(tmpV2);
if (tmpSolution < minTmp)
{
minTmp = tmpSolution;
}
}
return minTmp;
}
int main(int argc,char** argv)
{
cout << "Enter all days you want to take subway:\n";
vector<int> tmpV;
while( true )
{
int a;
cin >>a;
if(a!=-1)
{
tmpV.push_back(a);
}else
{
break;
}
}
cout << "\nInputDays:[";
for(int j =0; j < tmpV.size(); ++j)
{
cout << tmpV[j] << "\t" ;
}
cout << "]\n";
cout << "Min TicketFare: " << solution(tmpV) << endl;
return 0;
}