#include "squad.h"
#include<algorithm>
using namespace std;
#define INF 4'000'000'000'000'000'000LL
#define ll long long
int N;
vector<int> a, d, p;
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){
ll res = 0, mx = -INF;
for (int i = 0; i < N; i++)
{
ll val = (ll)X*d[i] + (ll)Y * p[i];
res = max(res, mx + val);
ll add = (ll)X*a[i] + (ll)Y*p[i];
mx = max(mx, add);
}
mx = -INF;
for (int i = 0; i < N; i++)
{
ll val = (ll)X*a[i] + (ll)Y * p[i];
res = max(res, mx + val);
ll add = (ll)X*d[i] + (ll)Y*p[i];
mx = max(mx, add);
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
169 ms |
10744 KB |
Output is correct |
4 |
Correct |
170 ms |
11000 KB |
Output is correct |
5 |
Correct |
15 ms |
1024 KB |
Output is correct |
6 |
Correct |
167 ms |
10876 KB |
Output is correct |
7 |
Correct |
174 ms |
10744 KB |
Output is correct |
8 |
Correct |
164 ms |
10872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
43 ms |
256 KB |
Output is correct |
3 |
Execution timed out |
3100 ms |
10872 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 |
384 KB |
Output is correct |
3 |
Correct |
169 ms |
10744 KB |
Output is correct |
4 |
Correct |
170 ms |
11000 KB |
Output is correct |
5 |
Correct |
15 ms |
1024 KB |
Output is correct |
6 |
Correct |
167 ms |
10876 KB |
Output is correct |
7 |
Correct |
174 ms |
10744 KB |
Output is correct |
8 |
Correct |
164 ms |
10872 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
43 ms |
256 KB |
Output is correct |
11 |
Execution timed out |
3100 ms |
10872 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |