#include "squad.h"
#include<algorithm>
using namespace std;
int N;
vector<long long>A,D,P;
void Init(std::vector<int> A, std::vector<int> D, std::vector<int> P){
N = A.size();
::A=vector<long long>(A.begin(),A.end());
::D=vector<long long>(D.begin(),D.end());
::P=vector<long long>(P.begin(),P.end());
}
long long BestSquad(int X, int Y){
vector<long long>S(N),T(N),U(N),V(N);
for(int i=0;i<N;i++){
U[i]=A[i]*X+P[i]*Y;
V[i]=D[i]*X+P[i]*Y;
S[i]=T[i]=i;
}
sort(S.begin(),S.end(),[&](int i,int j){return U[i]>U[j];});
sort(T.begin(),T.end(),[&](int i,int j){return V[i]>V[j];});
if(S[0]!=T[0])return U[S[0]]+V[T[0]];
return max(U[S[0]]+V[T[1]],U[S[1]]+V[T[0]]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
131 ms |
28888 KB |
Output is correct |
4 |
Correct |
129 ms |
28912 KB |
Output is correct |
5 |
Correct |
8 ms |
2284 KB |
Output is correct |
6 |
Correct |
130 ms |
28940 KB |
Output is correct |
7 |
Correct |
129 ms |
28824 KB |
Output is correct |
8 |
Correct |
133 ms |
28948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
626 ms |
596 KB |
Output is correct |
3 |
Execution timed out |
3039 ms |
26940 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
131 ms |
28888 KB |
Output is correct |
4 |
Correct |
129 ms |
28912 KB |
Output is correct |
5 |
Correct |
8 ms |
2284 KB |
Output is correct |
6 |
Correct |
130 ms |
28940 KB |
Output is correct |
7 |
Correct |
129 ms |
28824 KB |
Output is correct |
8 |
Correct |
133 ms |
28948 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
626 ms |
596 KB |
Output is correct |
11 |
Execution timed out |
3039 ms |
26940 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |