#include "squad.h"
#include <algorithm>
#include <functional>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<ll, int> pli;
vector<pli> k;
vector<int> aa, bb, cc;
int n;
void Init(std::vector<int> a, std::vector<int> b, std::vector<int> c){
n = a.size();
aa = a; bb = b; cc = c;
}
long long BestSquad(int x, int y){
ll mav = 0;
for (int i = 0; i < n; i++)
k.push_back({ (ll)x * bb[i] + (ll)y * cc[i], i });
sort(all(k), greater<pli>());
for (int i = 0; i < n; i++) {
if (i != k[0].second) {
mav = max(mav, k[0].first + aa[i] * (ll)x + cc[i] * (ll)y);
}
else {
mav = max(mav, k[1].first + aa[i] * (ll)x + cc[i] * (ll)y);
}
}
return mav;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
210 ms |
17552 KB |
Output is correct |
4 |
Correct |
209 ms |
17720 KB |
Output is correct |
5 |
Correct |
19 ms |
1664 KB |
Output is correct |
6 |
Correct |
208 ms |
17720 KB |
Output is correct |
7 |
Correct |
194 ms |
17720 KB |
Output is correct |
8 |
Correct |
201 ms |
17724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
210 ms |
17552 KB |
Output is correct |
4 |
Correct |
209 ms |
17720 KB |
Output is correct |
5 |
Correct |
19 ms |
1664 KB |
Output is correct |
6 |
Correct |
208 ms |
17720 KB |
Output is correct |
7 |
Correct |
194 ms |
17720 KB |
Output is correct |
8 |
Correct |
201 ms |
17724 KB |
Output is correct |
9 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |