Submission #145052

#TimeUsernameProblemLanguageResultExecution timeMemory
145052faremyCloud Computing (CEOI18_clo)C++14
100 / 100
415 ms1372 KiB
#include <iostream> #include <algorithm> struct Computer { int cores, freq; long long price; bool operator <(const Computer &other) const { if (freq != other.freq) return (other.freq < freq); return (other.cores < cores); } }; const int MAXN = 4e3; const int MAXC = 1e5 + 1; const long long NOPE = -1e18; Computer choice[MAXN]; long long benef[MAXC]; int main() { std::ios::sync_with_stdio(false); std::cout.tie(nullptr); std::cin.tie(nullptr); int computers; std::cin >> computers; for (int iComp = 0; iComp < computers; iComp++) std::cin >> choice[iComp].cores >> choice[iComp].freq >> choice[iComp].price; int orders; std::cin >> orders; for (int iOrd = computers; iOrd < computers + orders; iOrd++) { std::cin >> choice[iOrd].cores >> choice[iOrd].freq >> choice[iOrd].price; choice[iOrd].cores *= -1; } std::sort(choice, choice + computers + orders); std::fill_n(benef, MAXC, NOPE); benef[0] = 0; for (int iChoice = 0; iChoice < computers + orders; iChoice++) { if (choice[iChoice].cores > 0) for (int iCore = MAXC - 1 - choice[iChoice].cores; iCore > -1; iCore--) benef[iCore + choice[iChoice].cores] = std::max(benef[iCore + choice[iChoice].cores], benef[iCore] - choice[iChoice].price); else for (int iCore = -choice[iChoice].cores; iCore < MAXC; iCore++) benef[iCore + choice[iChoice].cores] = std::max(benef[iCore + choice[iChoice].cores], benef[iCore] + choice[iChoice].price); } long long maxBenef = 0; for (int iCore = 0; iCore < MAXC; iCore++) maxBenef = std::max(maxBenef, benef[iCore]); std::cout << maxBenef << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...