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){
long long firstA = 0, secondA = 0, firstD = 0, secondD = 0;
int firstAidx = 0, firstDidx = 0;
for (int i = 0; i < N; i++) {
long long A, D;
A = (long long)arr1[i] * (long long)X + (long long)arr3[i] * (long long)Y;
D = (long long)arr2[i] * (long long)X + (long long)arr3[i] * (long long)Y;
if (secondA <= A && A < firstA) {
secondA = A;
}
if (secondD <= D && D < firstD) {
secondD = D;
}
if (A >= firstA) {
secondA = firstA;
firstA = A;
firstAidx = i;
}
if (D >= firstD) {
secondD = firstD;
firstD = D;
firstDidx = i;
}
}
if (firstAidx == firstDidx) {
return firstA + secondD > firstD + secondA ? firstA + secondD : firstD + secondA;
}
else {
return firstA + firstD;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |