This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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);
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |