Submission #151653

#TimeUsernameProblemLanguageResultExecution timeMemory
151653baikdohyupOrganizing the Best Squad (FXCUP4_squad)C++17
19 / 100
3015 ms11000 KiB
#include "squad.h" #include <algorithm> #include <iostream> std::vector<int> arr1, arr2, arr3; int N; void Init(std::vector<int> A, std::vector<int> D, std::vector<int> P){ N = A.size(); arr1 = A; arr2 = D; arr3 = P; } long long BestSquad(int X, int Y){ long long firstA = 0, secondA = 0, firstD = 0, secondD = 0; int firstAidx = 0, firstDidx = 0; for (int i = 0; i < N; i++) { long long A, D; A = (long long)arr1[i] * (long long)X + (long long)arr3[i] * (long long)Y; D = (long long)arr2[i] * (long long)X + (long long)arr3[i] * (long long)Y; if (secondA <= A && A < firstA) { secondA = A; } if (secondD <= D && D < firstD) { secondD = D; } if (A >= firstA) { secondA = firstA; firstA = A; firstAidx = i; } if (D >= firstD) { secondD = firstD; firstD = D; firstDidx = i; } } if (firstAidx == firstDidx) { return firstA + secondD > firstD + secondA ? firstA + secondD : firstD + secondA; } else { return firstA + firstD; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...