This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "squad.h"
#include <algorithm>
#include <iostream>
std::vector<int> arr1, arr2, arr3;
int N;
void Init(std::vector<int> A, std::vector<int> D, std::vector<int> P){
N = A.size();
arr1 = A;
arr2 = D;
arr3 = P;
}
long long BestSquad(int X, int Y){
std::vector<std::pair<long long, int>> attack;
std::vector<std::pair<long long, int>> defense;
for (int i = 0; i < N; i++) {
attack.push_back(std::pair<long long, int>((long long)arr1[i] * (long long)X + (long long)arr3[i] * (long long)Y, i));
defense.push_back(std::pair<long long, int>((long long)arr2[i] * (long long)X + (long long)arr3[i] * (long long)Y, i));
}
sort(attack.begin(), attack.end());
sort(defense.begin(), defense.end());
if (attack.back().second == defense.back().second) {
return attack[N - 1].first + defense[N - 2].first > attack[N - 2].first + defense[N - 1].first ? attack[N - 1].first + defense[N - 2].first : attack[N - 2].first + defense[N - 1].first;
}
else {
return attack[N - 1].first + defense[N - 1].first;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |