#include "squad.h"
#include <utility>
#include <algorithm>
using namespace std;
vector<int> A, D, P;
int N;
pair<long long, long long> t1[300001],t2[300001];
void Init(std::vector<int> A_, std::vector<int> D_, std::vector<int> P_){
N = A_.size();
A = A_; D = D_; P = P_;
}
long long BestSquad(int X, int Y){
long long ret = -1;
if(N < 10){
for(int i = 0; i < N; i++){
for(int j = 0; j < N; j++){
if(i==j) continue;
ret = max(ret, 1ll*X*(A[i]+D[j])+1ll*Y*(P[i]+P[j]));
}
}
return ret;
}
for(int i = 0; i < N; i++){
t1[i] = {1ll*X*A[i]+1ll*Y*P[i],i};
t2[i] = {1ll*X*D[i]+1ll*Y*P[i],i};
}
sort(t1,t1+N);
sort(t2,t2+N);
for(int i = N-1; i >= N-5; i--){
for(int j = N-1; j >= N-5; j--){
if(i<0) continue;
if(j<0) continue;
if(t1[i].second == t2[j].second) continue;
ret = max(ret,t1[i].first+t2[j].first);
}
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
3 |
Correct |
235 ms |
16824 KB |
Output is correct |
4 |
Correct |
230 ms |
16852 KB |
Output is correct |
5 |
Correct |
19 ms |
1664 KB |
Output is correct |
6 |
Correct |
225 ms |
16828 KB |
Output is correct |
7 |
Correct |
233 ms |
16828 KB |
Output is correct |
8 |
Correct |
224 ms |
16828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
759 ms |
632 KB |
Output is correct |
3 |
Execution timed out |
3100 ms |
16828 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
3 |
Correct |
235 ms |
16824 KB |
Output is correct |
4 |
Correct |
230 ms |
16852 KB |
Output is correct |
5 |
Correct |
19 ms |
1664 KB |
Output is correct |
6 |
Correct |
225 ms |
16828 KB |
Output is correct |
7 |
Correct |
233 ms |
16828 KB |
Output is correct |
8 |
Correct |
224 ms |
16828 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
759 ms |
632 KB |
Output is correct |
11 |
Execution timed out |
3100 ms |
16828 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |