#include "squad.h"
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define ii pair<ll,ll>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
vii DP,AP;
v a,d,p;
int n;
void Init(v A, v D, v P){
a=A,d=D,p=P;
n = A.size();
DP.resize(n),AP.resize(n);
}
ll BestSquad(int X, int Y){
ll MX=0,MX1=0;
for (int i = 0; i < n; ++i)
{
DP[i]=ii((ll)X*(ll)d[i]+(ll)Y*(ll)p[i],i);
AP[i]=ii((ll)X*(ll)a[i]+(ll)Y*(ll)p[i],i);
}
sort(all(DP)),sort(all(AP));
for (int i = n-1; i >= 0; i--)
{
if(AP[i].se==DP[n-1].se)continue;
MX=AP[i].fi+DP[n-1].fi;
break;
}
for (int i = n-1; i >= 0; i--)
{
if(DP[i].se==AP[n-1].se)continue;
MX1=AP[n-1].fi+DP[i].fi;
break;
}
return max(MX,MX1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
227 ms |
20344 KB |
Output is correct |
4 |
Correct |
237 ms |
20348 KB |
Output is correct |
5 |
Correct |
22 ms |
1664 KB |
Output is correct |
6 |
Correct |
231 ms |
20344 KB |
Output is correct |
7 |
Correct |
238 ms |
20344 KB |
Output is correct |
8 |
Correct |
237 ms |
20336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
792 ms |
636 KB |
Output is correct |
3 |
Execution timed out |
3098 ms |
20344 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
227 ms |
20344 KB |
Output is correct |
4 |
Correct |
237 ms |
20348 KB |
Output is correct |
5 |
Correct |
22 ms |
1664 KB |
Output is correct |
6 |
Correct |
231 ms |
20344 KB |
Output is correct |
7 |
Correct |
238 ms |
20344 KB |
Output is correct |
8 |
Correct |
237 ms |
20336 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
792 ms |
636 KB |
Output is correct |
11 |
Execution timed out |
3098 ms |
20344 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |