Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <vector>
- #include <queue>
- #include <set>
- #include <map>
- #include <cstdio>
- #include <cstdlib>
- #include <cctype>
- #include <cmath>
- using namespace std;
- typedef long long LL;
- #define FOR(k,a,b) for(int k(a); k < (b); ++k)
- #define REP(k,a) for(int k=0; k < (a); ++k)
- class FeudaliasBattle {
- vector<int> mBX,mBY,mSX,mSY;
- double mTOT,mRT,mMS;
- double dist(double x1, double y1, double x2, double y2)
- {
- return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
- }
- double destroyS(int b, int s)
- {
- double res=mTOT;
- res+=dist(mBX[b],mBY[b],mSX[s],mSY[s])/mMS;
- return res;
- }
- double destroyD(int b)
- {
- double res,res2,res3,res4;
- res=mTOT+dist(mBX[0],mBY[0],mSX[b],mSY[b])/mMS;
- res2=2*mTOT+mRT+dist(mBX[1],mBY[1],mSX[b],mSY[b])/mMS;
- res3=mTOT+dist(mBX[1],mBY[1],mSX[b],mSY[b])/mMS;
- res4=2*mTOT+mRT+dist(mBX[0],mBY[0],mSX[b],mSY[b])/mMS;
- return min(max(res,res2),max(res3,res4));
- }
- public:
- double getMinimumTime(vector <int> baseX, vector <int> baseY, vector <int> siloX, vector <int> siloY, int takeOffTime, int rechargeTime, int missileSpeed) {
- mBX=baseX,mBY=baseY,mSX=siloX,mSY=siloY;
- mTOT=takeOffTime/60.0,mRT=rechargeTime,mMS=missileSpeed;
- double res=destroyD(0);
- res=min(res,destroyD(1));
- REP(i,2)
- {
- res=min(res,max(destroyS(i,0),destroyS(1-i,1)));
- res=min(res,max(destroyS(1-i,0),destroyS(i,1)));
- }
- return res;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment