Submission #1322384

#TimeUsernameProblemLanguageResultExecution timeMemory
1322384sjoxuzchloeCloud Computing (CEOI18_clo)C++20
100 / 100
288 ms1276 KiB
// ConsoleApplication160.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> #include <vector> #include <algorithm> #include <climits> using namespace std; typedef long long ll; const ll NEG = LLONG_MIN / 4; struct Computers { int c;ll f, p; bool operator<(const Computers &other) const { return f > other.f; } }; struct Order { int c; ll f, p; bool operator<(const Order& other) const { return f > other.f; } }; int main() { int n; cin >> n; vector<Computers> cores(n); int coresnum = 0; for (int i = 0; i < n; i++) { cin >> cores[i].c >> cores[i].f >> cores[i].p; coresnum += cores[i].c; } sort(cores.begin(), cores.end()); int m; cin >> m; vector<Order> orders(m); for (int i = 0; i < m; i++) { cin >> orders[i].c >> orders[i].f >> orders[i].p; } sort(orders.begin(), orders.end()); vector<ll> dp(coresnum + 1, NEG); dp[0] = 0; int i = 0, j = 0; int maxi = 0; while (i < n || j < m) { if (j == m || i < n && cores[i].f >= orders[j].f) { for (int w = coresnum - cores[i].c; w >= 0; w--) { if (dp[w] != NEG) dp[w + cores[i].c] = max(dp[w + cores[i].c], dp[w] - cores[i].p); } maxi += cores[i].c; i++; } else { for (int w = orders[j].c; w <= maxi; w++) { if (dp[w] != NEG) dp[w - orders[j].c] = max(dp[w] + orders[j].p, dp[w - orders[j].c]); } j++; } } ll ma = 0; for (ll v : dp) { ma = max(ma, v); } cout << ma << "\n"; } // Run program: Ctrl + F5 or Debug > Start Without Debugging menu // Debug program: F5 or Debug > Start Debugging menu // Tips for Getting Started: // 1. Use the Solution Explorer window to add/manage files // 2. Use the Team Explorer window to connect to source control // 3. Use the Output window to see build output and other messages // 4. Use the Error List window to view errors // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
#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...