|
| 1 | +#line 2 "TheAirTripDivTwo.cpp" |
| 2 | +#include <vector> |
| 3 | +#include <list> |
| 4 | +#include <map> |
| 5 | +#include <set> |
| 6 | +#include <deque> |
| 7 | +#include <stack> |
| 8 | +#include <bitset> |
| 9 | +#include <algorithm> |
| 10 | +#include <functional> |
| 11 | +#include <numeric> |
| 12 | +#include <utility> |
| 13 | +#include <sstream> |
| 14 | +#include <iostream> |
| 15 | +#include <iomanip> |
| 16 | +#include <cstdio> |
| 17 | +#include <cmath> |
| 18 | +#include <cstdlib> |
| 19 | +#include <ctime> |
| 20 | +#include <cstring> |
| 21 | +#define lli long long int |
| 22 | +#define llu unsigned long long int |
| 23 | +#define S(x) scanf("%d",&x) |
| 24 | +#define Sl(x) scanf("%lld",&x) |
| 25 | +#define Mset(p,i) memset(p,i,sizeof(p)) |
| 26 | +#define mlc(t,n) (t *)malloc(sizeof(t)*n) |
| 27 | +#define NIL -1 |
| 28 | +#define INF 0x3f3f3f3f |
| 29 | +#define TC int testcase; S(testcase); while(testcase--) |
| 30 | +#define Pi 3.14159 |
| 31 | +using namespace std; |
| 32 | + |
| 33 | +class TheAirTripDivTwo |
| 34 | +{ |
| 35 | + public: |
| 36 | + int find(vector <int> flights, int fuel) |
| 37 | + { |
| 38 | + if(flights.size() == 1 && fuel >= flights[0]) |
| 39 | + return 1; |
| 40 | + int i; |
| 41 | + for(i=0;i<flights.size();i++) |
| 42 | + { |
| 43 | + if(fuel < 0) |
| 44 | + return i-1; |
| 45 | + fuel -= flights[i]; |
| 46 | + |
| 47 | + } |
| 48 | + |
| 49 | + return i-1; |
| 50 | + } |
| 51 | +}; |
| 52 | +// BEGIN CUT HERE |
| 53 | +#include <ctime> |
| 54 | +#include <cmath> |
| 55 | +#include <string> |
| 56 | +#include <vector> |
| 57 | +#include <sstream> |
| 58 | +#include <iostream> |
| 59 | +#include <algorithm> |
| 60 | +using namespace std; |
| 61 | + |
| 62 | +int main(int argc, char* argv[]) |
| 63 | +{ |
| 64 | + if (argc == 1) |
| 65 | + { |
| 66 | + cout << "Testing TheAirTripDivTwo (250.0 points)" << endl << endl; |
| 67 | + for (int i = 0; i < 20; i++) |
| 68 | + { |
| 69 | + ostringstream s; s << argv[0] << " " << i; |
| 70 | + int exitCode = system(s.str().c_str()); |
| 71 | + if (exitCode) |
| 72 | + cout << "#" << i << ": Runtime Error" << endl; |
| 73 | + } |
| 74 | + int T = time(NULL)-1497118059; |
| 75 | + double PT = T/60.0, TT = 75.0; |
| 76 | + cout.setf(ios::fixed,ios::floatfield); |
| 77 | + cout.precision(2); |
| 78 | + cout << endl; |
| 79 | + cout << "Time : " << T/60 << " minutes " << T%60 << " secs" << endl; |
| 80 | + cout << "Score : " << 250.0*(.3+(.7*TT*TT)/(10.0*PT*PT+TT*TT)) << " points" << endl; |
| 81 | + } |
| 82 | + else |
| 83 | + { |
| 84 | + int _tc; istringstream(argv[1]) >> _tc; |
| 85 | + TheAirTripDivTwo _obj; |
| 86 | + int _expected, _received; |
| 87 | + time_t _start = clock(); |
| 88 | + switch (_tc) |
| 89 | + { |
| 90 | + case 0: |
| 91 | + { |
| 92 | + int flights[] = {1, 2, 3, 4, 5, 6, 7}; |
| 93 | + int fuel = 10; |
| 94 | + _expected = 4; |
| 95 | + _received = _obj.find(vector <int>(flights, flights+sizeof(flights)/sizeof(int)), fuel); break; |
| 96 | + } |
| 97 | + case 1: |
| 98 | + { |
| 99 | + int flights[] = {7, 6, 5, 4, 3, 2, 1}; |
| 100 | + int fuel = 10; |
| 101 | + _expected = 1; |
| 102 | + _received = _obj.find(vector <int>(flights, flights+sizeof(flights)/sizeof(int)), fuel); break; |
| 103 | + } |
| 104 | + case 2: |
| 105 | + { |
| 106 | + int flights[] = {1}; |
| 107 | + int fuel = 1000; |
| 108 | + _expected = 1; |
| 109 | + _received = _obj.find(vector <int>(flights, flights+sizeof(flights)/sizeof(int)), fuel); break; |
| 110 | + } |
| 111 | + case 3: |
| 112 | + { |
| 113 | + int flights[] = {8, 7, 7, 1, 5, 7, 9}; |
| 114 | + int fuel = 21; |
| 115 | + _expected = 2; |
| 116 | + _received = _obj.find(vector <int>(flights, flights+sizeof(flights)/sizeof(int)), fuel); break; |
| 117 | + } |
| 118 | + /*case 4: |
| 119 | + { |
| 120 | + int flights[] = ; |
| 121 | + int fuel = ; |
| 122 | + _expected = ; |
| 123 | + _received = _obj.find(vector <int>(flights, flights+sizeof(flights)/sizeof(int)), fuel); break; |
| 124 | + }*/ |
| 125 | + /*case 5: |
| 126 | + { |
| 127 | + int flights[] = ; |
| 128 | + int fuel = ; |
| 129 | + _expected = ; |
| 130 | + _received = _obj.find(vector <int>(flights, flights+sizeof(flights)/sizeof(int)), fuel); break; |
| 131 | + }*/ |
| 132 | + /*case 6: |
| 133 | + { |
| 134 | + int flights[] = ; |
| 135 | + int fuel = ; |
| 136 | + _expected = ; |
| 137 | + _received = _obj.find(vector <int>(flights, flights+sizeof(flights)/sizeof(int)), fuel); break; |
| 138 | + }*/ |
| 139 | + default: return 0; |
| 140 | + } |
| 141 | + cout.setf(ios::fixed,ios::floatfield); |
| 142 | + cout.precision(2); |
| 143 | + double _elapsed = (double)(clock()-_start)/CLOCKS_PER_SEC; |
| 144 | + if (_received == _expected) |
| 145 | + cout << "#" << _tc << ": Passed (" << _elapsed << " secs)" << endl; |
| 146 | + else |
| 147 | + { |
| 148 | + cout << "#" << _tc << ": Failed (" << _elapsed << " secs)" << endl; |
| 149 | + cout << " Expected: " << _expected << endl; |
| 150 | + cout << " Received: " << _received << endl; |
| 151 | + } |
| 152 | + } |
| 153 | +} |
| 154 | + |
| 155 | +// END CUT HERE |
| 156 | + |
| 157 | + |
0 commit comments