#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 |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
247 ms |
31884 KB |
Output is correct |
4 |
Correct |
246 ms |
31836 KB |
Output is correct |
5 |
Correct |
16 ms |
2424 KB |
Output is correct |
6 |
Correct |
247 ms |
31832 KB |
Output is correct |
7 |
Correct |
245 ms |
31792 KB |
Output is correct |
8 |
Correct |
246 ms |
31792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
1066 ms |
932 KB |
Output is correct |
3 |
Execution timed out |
3045 ms |
32508 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
247 ms |
31884 KB |
Output is correct |
4 |
Correct |
246 ms |
31836 KB |
Output is correct |
5 |
Correct |
16 ms |
2424 KB |
Output is correct |
6 |
Correct |
247 ms |
31832 KB |
Output is correct |
7 |
Correct |
245 ms |
31792 KB |
Output is correct |
8 |
Correct |
246 ms |
31792 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
1066 ms |
932 KB |
Output is correct |
11 |
Execution timed out |
3045 ms |
32508 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |