#include "squad.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, dcond;
ll atk[300002], def[300002], pop[300002];
vector<pair<ll, int> > atkVec, defVec;
ll optimal;
void Init(vector<int> A, vector<int> D, vector<int> P){
n = (int)A.size(), dcond = 1;
for(int i=1; i<=n; i++){
atk[i] = A[i-1];
def[i] = D[i-1];
pop[i] = P[i-1];
if(def[i] != 1) dcond = 0;
}
if(dcond){
for(int i=1; i<=n; i++) atkVec.push_back(make_pair(atk[i], i));
for(int i=1; i<=n; i++) defVec.push_back(make_pair(def[i], i));
sort(atkVec.rbegin(), atkVec.rend());
sort(defVec.rbegin(), defVec.rend());
if(atkVec[0].second != defVec[0].second) optimal = atkVec[0].first + defVec[0].first;
else optimal = max(atkVec[0].first + defVec[1].first, atkVec[1].first + defVec[0].first);
}
}
ll BestSquad(int X, int Y){
if(dcond){
for(int i=1; i<=n; i++) atkVec.push_back(make_pair(atk[i]*X+pop[i]*Y, i));
for(int i=1; i<=n; i++) defVec.push_back(make_pair(def[i]*X+pop[i]*Y, i));
sort(atkVec.rbegin(), atkVec.rend());
sort(defVec.rbegin(), defVec.rend());
if(atkVec[0].second != defVec[0].second) return atkVec[0].first + defVec[0].first;
else return max(atkVec[0].first + defVec[1].first, atkVec[1].first + defVec[0].first);
}
else{
return optimal * X + Y * 2;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |