Artifact Content
Not logged in

Artifact 569c7cb5f3c676efeaf080a98659f15928f791f6


#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 TheAirTripDivTwo { public:
	int find(vector <int> flights, int fuel) 
	{
		partial_sum(flights.begin(), flights.end(), flights.begin());
		return upper_bound(flights.begin(), flights.end(), fuel) - flights.begin();
	}
};

// 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(_, TheAirTripDivTwo().find(flights, fuel));}
int main(){

CASE(0)
	int flights_[] = {1, 2, 3, 4, 5, 6, 7};
	  vector <int> flights(flights_, flights_+sizeof(flights_)/sizeof(*flights_)); 
	int fuel = 10; 
	int _ = 4; 
END
CASE(1)
	int flights_[] = {7, 6, 5, 4, 3, 2, 1};
	  vector <int> flights(flights_, flights_+sizeof(flights_)/sizeof(*flights_)); 
	int fuel = 10; 
	int _ = 1; 
END
CASE(2)
	int flights_[] = {1};
	  vector <int> flights(flights_, flights_+sizeof(flights_)/sizeof(*flights_)); 
	int fuel = 1000; 
	int _ = 1; 
END
CASE(3)
	int flights_[] = {8, 7, 7, 1, 5, 7, 9};
	  vector <int> flights(flights_, flights_+sizeof(flights_)/sizeof(*flights_)); 
	int fuel = 21; 
	int _ = 2; 
END
	/*
CASE(4)
	int flights_[] = ;
	  vector <int> flights(flights_, flights_+sizeof(flights_)/sizeof(*flights_)); 
	int fuel = ; 
	int _ = ; 
END
CASE(5)
	int flights_[] = ;
	  vector <int> flights(flights_, flights_+sizeof(flights_)/sizeof(*flights_)); 
	int fuel = ; 
	int _ = ; 
END
*/
}
// END CUT HERE