#include "squad.h"
#include <vector>
#include <algorithm>
using namespace std;
int N;
vector<int> A;
vector<int> D;
vector<int> P;
void Init(std::vector<int> AA, std::vector<int> DD, std::vector<int> PP){
N = AA.size();
A = AA;
D = DD;
P = PP;
return;
}
long long BestSquad(int X, int Y){
vector<pair<long long, int>> x;
vector<pair<long long, int>> y;
for(int i=0; i<N; i++){
x.push_back({-1LL*A[i]*X-1LL*P[i]*Y, i});
y.push_back({-1LL*D[i]*X-1LL*P[i]*Y, i});
}
sort(x.begin(), x.end());
sort(y.begin(), y.end());
long long res = 0;
for(int i=0; i<2; i++){
for(int j=0; j<2; j++){
if(x[i].second == y[j].second) continue;
res = max(res, -x[i].first-y[j].first);
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
3 |
Correct |
247 ms |
23096 KB |
Output is correct |
4 |
Correct |
249 ms |
23096 KB |
Output is correct |
5 |
Correct |
20 ms |
2044 KB |
Output is correct |
6 |
Correct |
236 ms |
23096 KB |
Output is correct |
7 |
Correct |
250 ms |
23224 KB |
Output is correct |
8 |
Correct |
240 ms |
23096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
991 ms |
644 KB |
Output is correct |
3 |
Execution timed out |
3101 ms |
25864 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
3 |
Correct |
247 ms |
23096 KB |
Output is correct |
4 |
Correct |
249 ms |
23096 KB |
Output is correct |
5 |
Correct |
20 ms |
2044 KB |
Output is correct |
6 |
Correct |
236 ms |
23096 KB |
Output is correct |
7 |
Correct |
250 ms |
23224 KB |
Output is correct |
8 |
Correct |
240 ms |
23096 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
991 ms |
644 KB |
Output is correct |
11 |
Execution timed out |
3101 ms |
25864 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |