#include "squad.h"
#include <algorithm>
typedef std::pair<long long,long long> pii;
std::vector<int> a,d,p;
std::vector<pii> al,dl,pl;
int n;
void Init(std::vector<int> A, std::vector<int> D, std::vector<int> P){
int N = A.size();
n=N;
a=A;
d=D;
p=P;
}
long long BestSquad(int X, int Y){
for(int i=0; i<n; i++)
{
pl.push_back(pii((long long)p[i]*(long long)Y,i));
al.push_back(pii((long long)a[i]*(long long)X+pl[i].first,i));
dl.push_back(pii((long long)d[i]*(long long)X+pl[i].first,i));
}
std::sort(al.begin(),al.end());
std::sort(dl.begin(),dl.end());
std::sort(pl.begin(),pl.end());
long long maxi = 0;
int m = 2;
for(int i=1; i<=m; i++)
{
for(int j=1; j<=m; j++)
{
if(al[n-i].second!=dl[n-j].second)
{
maxi = (maxi>al[n-i].first+dl[n-j].first)?maxi:al[n-i].first+dl[n-j].first;
}
}
}
return maxi;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
3 |
Correct |
303 ms |
23988 KB |
Output is correct |
4 |
Correct |
295 ms |
23988 KB |
Output is correct |
5 |
Correct |
24 ms |
2296 KB |
Output is correct |
6 |
Correct |
297 ms |
23988 KB |
Output is correct |
7 |
Correct |
294 ms |
24008 KB |
Output is correct |
8 |
Correct |
300 ms |
23988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
3 |
Correct |
303 ms |
23988 KB |
Output is correct |
4 |
Correct |
295 ms |
23988 KB |
Output is correct |
5 |
Correct |
24 ms |
2296 KB |
Output is correct |
6 |
Correct |
297 ms |
23988 KB |
Output is correct |
7 |
Correct |
294 ms |
24008 KB |
Output is correct |
8 |
Correct |
300 ms |
23988 KB |
Output is correct |
9 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |