#include "squad.h"
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second
using namespace std;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
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)
{
i64 ans = 0;
vector<i64> as(n), ds(n), ps(n);
multiset<i64> ms;
for (int i = 0; i < n; i++)
{
as[i] = a[i];
as[i] *= X;
ds[i] = d[i];
ds[i] *= X;
ps[i] = p[i];
ps[i] *= Y;
ms.insert(ds[i] + ps[i]);
}
for (int i = 0; i < n; i++)
{
ms.erase(ms.find(ds[i] + ps[i]));
ans = max(ans, *ms.rbegin() + as[i] + ps[i]);
ms.insert(ds[i] + ps[i]);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
3 |
Correct |
784 ms |
28604 KB |
Output is correct |
4 |
Correct |
752 ms |
28604 KB |
Output is correct |
5 |
Correct |
32 ms |
2048 KB |
Output is correct |
6 |
Correct |
800 ms |
28476 KB |
Output is correct |
7 |
Correct |
784 ms |
28604 KB |
Output is correct |
8 |
Correct |
738 ms |
28600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
2871 ms |
640 KB |
Output is correct |
3 |
Execution timed out |
3101 ms |
28432 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 |
512 KB |
Output is correct |
3 |
Correct |
784 ms |
28604 KB |
Output is correct |
4 |
Correct |
752 ms |
28604 KB |
Output is correct |
5 |
Correct |
32 ms |
2048 KB |
Output is correct |
6 |
Correct |
800 ms |
28476 KB |
Output is correct |
7 |
Correct |
784 ms |
28604 KB |
Output is correct |
8 |
Correct |
738 ms |
28600 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
2871 ms |
640 KB |
Output is correct |
11 |
Execution timed out |
3101 ms |
28432 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |