Submission #151641

#TimeUsernameProblemLanguageResultExecution timeMemory
151641baikdohyupOrganizing the Best Squad (FXCUP4_squad)C++17
19 / 100
3045 ms32508 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){ std::vector<std::pair<long long, int>> attack; std::vector<std::pair<long long, int>> defense; for (int i = 0; i < N; i++) { attack.push_back(std::pair<long long, int>((long long)arr1[i] * (long long)X + (long long)arr3[i] * (long long)Y, i)); defense.push_back(std::pair<long long, int>((long long)arr2[i] * (long long)X + (long long)arr3[i] * (long long)Y, i)); } sort(attack.begin(), attack.end()); sort(defense.begin(), defense.end()); if (attack.back().second == defense.back().second) { return attack[N - 1].first + defense[N - 2].first > attack[N - 2].first + defense[N - 1].first ? attack[N - 1].first + defense[N - 2].first : attack[N - 2].first + defense[N - 1].first; } else { return attack[N - 1].first + defense[N - 1].first; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...