Submission #488128

#TimeUsernameProblemLanguageResultExecution timeMemory
488128TruaShamuCloud Computing (CEOI18_clo)C++17
36 / 100
681 ms1872 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; #define pb push_back #define all(x) begin(x), end(x) #define sz(x) (int) (x).size() using pi = pair<int, int>; #define f first #define s second #define mp make_pair void setIO(string name = "") { cin.tie(0)->sync_with_stdio(0); // see /general/fast-io if (sz(name)) { freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output freopen((name + ".out").c_str(), "w", stdout); } } struct event { int cores; int rate; int price; bool operator < (const event& b) const { return rate != b.rate ? rate > b.rate : price < b.price; } }; int main() { setIO(); vector<event> events; int N; cin >> N; // Computer int maxComp = 0; for (int i = 0; i < N; i++) { event oEvent; cin >> oEvent.cores >> oEvent.rate >> oEvent.price; oEvent.price *= -1; events.pb(oEvent); maxComp += oEvent.cores; } // Order int M; cin >> M; for (int i = 0; i < M; i++) { event oEvent; cin >> oEvent.cores >> oEvent.rate >> oEvent.price; oEvent.cores *= -1; events.pb(oEvent); } // Print std::sort(events.begin(), events.end()); vector<ll> dp(maxComp + 1, INT_MIN); dp[0] = 0; for (const event& oEvent : events) { vector<ll> newMax(dp); for (int c = 0; c <= maxComp; c++) { int prevComp = c - oEvent.cores; if (prevComp >= 0 && prevComp <= maxComp && dp[prevComp] != INT_MIN) { newMax[c] = max(newMax[c], dp[prevComp] + oEvent.price); } } dp = newMax; } cout << *max_element(dp.begin(), dp.end()); }

Compilation message (stderr)

clo.cpp: In function 'void setIO(std::string)':
clo.cpp:19:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:20:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   freopen((name + ".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...