Submission #759922

#TimeUsernameProblemLanguageResultExecution timeMemory
759922jk410Organizing the Best Squad (FXCUP4_squad)C++17
19 / 100
3061 ms29056 KiB
//subtask 1 #include <bits/stdc++.h> #include "squad.h" using namespace std; typedef long long ll; int n; vector<ll> a, d, p; void Init(std::vector<int> A, std::vector<int> D, std::vector<int> P){ n = (int)A.size(); for (int i = 0; i < n; i++) { a.push_back(A[i]); d.push_back(D[i]); p.push_back(P[i]); } } ll BestSquad(int X, int Y){ vector<ll> am(n), dm(n); vector<ll> pdm(n), sdm(n); for (int i = 0; i < n; i++) { am[i] = X * a[i] + Y * p[i]; dm[i] = X * d[i] + Y * p[i]; } pdm[0] = dm[0]; for (int i = 1; i < n; i++) pdm[i] = max(pdm[i - 1], dm[i]); sdm[n - 1] = dm[n - 1]; for (int i = n - 2; i >= 0; i--) sdm[i] = max(sdm[i + 1], dm[i]); ll ret = 0; for (int i = 0; i < n; i++) ret = max(ret, am[i] + max(i ? pdm[i - 1] : 0, i + 1 < n ? sdm[i + 1] : 0)); return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...