#include "squad.h"
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
//#include "boxes.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=3e5+50;
const int mod=1e9+7;
using namespace std;
int n,i;
ll cx,cy,a[nmax],d[nmax],p[nmax],pr[nmax],sf[nmax],rs;
void Init(vector<int> A,vector<int> D,vector<int> P)
{
n=A.size();
for(i=1;i<=n;i++)
{
a[i]=A[i-1];
d[i]=D[i-1];
p[i]=P[i-1];
}
}
ll BestSquad(int X,int Y)
{
cx=X,cy=Y,rs=0;
for(i=1;i<=n;i++)
{
pr[i]=max(pr[i-1],d[i]*cx+p[i]*cy);
}
for(i=n;i>=1;i--)
{
sf[i]=max(sf[i+1],d[i]*cx+p[i]*cy);
}
for(i=1;i<=n;i++)
{
rs=max(rs,a[i]*cx+p[i]*cy+max(pr[i-1],sf[i+1]));
}
return rs;
}
Compilation message
squad.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization("O3")
squad.cpp:4:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization("unroll-loops")
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
3 |
Correct |
176 ms |
15676 KB |
Output is correct |
4 |
Correct |
176 ms |
15676 KB |
Output is correct |
5 |
Correct |
19 ms |
1560 KB |
Output is correct |
6 |
Correct |
176 ms |
15676 KB |
Output is correct |
7 |
Correct |
178 ms |
15676 KB |
Output is correct |
8 |
Correct |
162 ms |
15676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
76 ms |
632 KB |
Output is correct |
3 |
Execution timed out |
3101 ms |
15676 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
3 |
Correct |
176 ms |
15676 KB |
Output is correct |
4 |
Correct |
176 ms |
15676 KB |
Output is correct |
5 |
Correct |
19 ms |
1560 KB |
Output is correct |
6 |
Correct |
176 ms |
15676 KB |
Output is correct |
7 |
Correct |
178 ms |
15676 KB |
Output is correct |
8 |
Correct |
162 ms |
15676 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
76 ms |
632 KB |
Output is correct |
11 |
Execution timed out |
3101 ms |
15676 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |