//subtask 1
#include <bits/stdc++.h>
#include "squad.h"
using namespace std;
typedef long long ll;
int n;
vector<ll> a, d, p;
void Init(std::vector<int> A, std::vector<int> D, std::vector<int> P){
n = (int)A.size();
for (int i = 0; i < n; i++) {
a.push_back(A[i]);
d.push_back(D[i]);
p.push_back(P[i]);
}
}
ll BestSquad(int X, int Y){
vector<ll> am(n), dm(n);
vector<ll> pdm(n), sdm(n);
for (int i = 0; i < n; i++) {
am[i] = X * a[i] + Y * p[i];
dm[i] = X * d[i] + Y * p[i];
}
pdm[0] = dm[0];
for (int i = 1; i < n; i++)
pdm[i] = max(pdm[i - 1], dm[i]);
sdm[n - 1] = dm[n - 1];
for (int i = n - 2; i >= 0; i--)
sdm[i] = max(sdm[i + 1], dm[i]);
ll ret = 0;
for (int i = 0; i < n; i++)
ret = max(ret, am[i] + max(i ? pdm[i - 1] : 0, i + 1 < n ? sdm[i + 1] : 0));
return ret;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
85 ms |
29024 KB |
Output is correct |
4 |
Correct |
83 ms |
29048 KB |
Output is correct |
5 |
Correct |
6 ms |
2248 KB |
Output is correct |
6 |
Correct |
82 ms |
29056 KB |
Output is correct |
7 |
Correct |
80 ms |
28980 KB |
Output is correct |
8 |
Correct |
80 ms |
29048 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
49 ms |
664 KB |
Output is correct |
3 |
Execution timed out |
3061 ms |
27036 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
85 ms |
29024 KB |
Output is correct |
4 |
Correct |
83 ms |
29048 KB |
Output is correct |
5 |
Correct |
6 ms |
2248 KB |
Output is correct |
6 |
Correct |
82 ms |
29056 KB |
Output is correct |
7 |
Correct |
80 ms |
28980 KB |
Output is correct |
8 |
Correct |
80 ms |
29048 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
49 ms |
664 KB |
Output is correct |
11 |
Execution timed out |
3061 ms |
27036 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |