#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++) {
if ((long long)arr1[i] * (long long)X + (long long)arr3[i] * (long long)Y >= firstA) {
secondA = firstA;
firstA = (long long)arr1[i] * (long long)X + (long long)arr3[i] * (long long)Y;
firstAidx = i;
}
if ((long long)arr2[i] * (long long)X + (long long)arr3[i] * (long long)Y >= firstD) {
secondD = firstD;
firstD = (long long)arr2[i] * (long long)X + (long long)arr3[i] * (long long)Y;
firstDidx = i;
}
}
if (firstAidx == firstDidx) {
return firstA + secondD > firstD + secondA ? firstA + secondD : firstD + secondA;
}
else {
return firstA + firstD;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
161 ms |
10936 KB |
Output is correct |
4 |
Correct |
159 ms |
10872 KB |
Output is correct |
5 |
Correct |
12 ms |
1016 KB |
Output is correct |
6 |
Incorrect |
159 ms |
11000 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
15 ms |
504 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
161 ms |
10936 KB |
Output is correct |
4 |
Correct |
159 ms |
10872 KB |
Output is correct |
5 |
Correct |
12 ms |
1016 KB |
Output is correct |
6 |
Incorrect |
159 ms |
11000 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |