Submission #150054

#TimeUsernameProblemLanguageResultExecution timeMemory
150054Cafe Maru (#200)Organizing the Best Squad (FXCUP4_squad)C++17
19 / 100
170 ms11004 KiB
#include "squad.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
vector<int> a,d,p;
void Init(std::vector<int> A, std::vector<int> D, std::vector<int> P){
    a = A;
    d = D;
    p = P;
}

pair<ll, ll> ad[2], bd[2];
long long BestSquad(int X, int Y){
    int n = a.size();
    for(int i=0;i<n;i++) {
        pair<ll,ll> ta = {1LL*X*a[i] + 1LL*Y*p[i], i};
        if(ta > ad[0]) {
            ad[1] = ad[0];
            ad[0] = ta;
        } else if (ta > ad[1]) {
            ad[1] = ta;
        }
        pair<ll,ll> tb = {1LL*X*d[i] + 1LL*Y*p[i], i};
        if (tb > bd[0]) {
            bd[1] = bd[0];
            bd[0] = tb;
        } else if (tb > bd[1]) {
            bd[1] = tb;
        }
    }
    if (ad[0].second != bd[0].second) {
        return ad[0].first + bd[0].first;
    } else {
        return max(ad[0].first + bd[1].first, ad[1].first+bd[0].first);
    }
}


/*
void Init(std::vector<int> A, std::vector<int> D, std::vector<int> P){
	int N = A.size();
}

long long BestSquad(int X, int Y){
	return 0;
}
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...