Submission #566464

#TimeUsernameProblemLanguageResultExecution timeMemory
566464drdilyorCloud Computing (CEOI18_clo)C++17
18 / 100
481 ms832 KiB
#ifdef ONPC //#define _GLIBCXX_DEBUG #define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__) #else #define debug(...) 42 #endif #define allit(a) (a).begin(), (a).end() #define memclr(a) memset(a, 0, sizeof(0)) #define sz(a) ((int) (a).size()) #include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; using vi = vector<int>; using vii = vector<pair<int, int>>; using vvi = vector<vector<int>>; template<typename T> using uset = unordered_set<T>; template<typename K, typename V> using umap = unordered_map<K, V>; //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/detail/standard_policies.hpp> //namespace pd = __gnu_pbds; //template<typename K> //using ordered_set = pd::tree< // K, // pd::null_type, // less<int>, // pd::rb_tree_tag, // pd::tree_order_statistics_node_update>; //using pd::gp_hash_table; void debug_out() { cerr << endl; } template<typename... Tail> void debug_out(vector<int> h, Tail... t) { cerr << "["; for (int i = 0; i < sz(h); i++) { if (i != 0) cerr << ", "; cerr << h[i]; } cerr << "]"; debug_out(t...); } template<typename P1, typename P2, typename... Tail> void debug_out(pair<P1, P2> h, Tail... t) { cerr << "[" << h.first << ", " << h.second << "]"; debug_out(t...); } template<typename Head, typename... Tail> void debug_out(Head h, Tail... t) { cerr << "[" << h << "]"; debug_out(t...); } const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count(); struct chash { int operator() (int x) const { return x ^ RANDOM; } }; const int INF = 1e9+1; const ll INFL = 1e18+1; const int N = 250; int solve(); signed main() { cin.tie(0)->sync_with_stdio(0); int t = 1; //cin >> t; while (t-- && cin) { if (solve()) break; #ifdef ONPC cout << "____________________" << endl; #endif } return 0; } int n, m; vector<array<int, 3>> computers; vector<array<int, 3>> orders; vi sold, accepted; const int C = 0, F = 1, V = 2; ll memo[N][N]; ll dp(int c, int o) { if (c == n) return 0; if (o == m) return 0; ll res = dp(c+1, o); if (memo[c][o] !=-1) return memo[c][o]; for (int i = o; i < m; i++) { int profit = orders[i][V] - computers[c][V]; if (profit <= 0 || orders[i][F] > computers[c][F]) continue; res = max(res, profit+dp(c+1, i+1)); } debug(c, o, res); return memo[c][o] = res; } int solve() { cin >> n; computers.reserve(n); for (int i = 0; i < n; i++) { int c, f, v; cin >> c >> f >> v; assert(c==1); computers.push_back({c, f, v}); } cin >> m; orders.reserve(m); for (int i = 0; i < m; i++) { int c, f, v; cin >> c >> f >> v; assert(c==1); orders.push_back({c, f, v}); } sold.resize(n); accepted.resize(m); sort(allit(computers), [](array<int,3> a, array<int,3> b) { return a[1] < b[1]; }); sort(allit(orders), [](array<int,3> a, array<int,3> b) { return a[1] < b[1]; }); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) memo[i][j] = -1; cout << dp(0, 0); return 0; }

Compilation message (stderr)

clo.cpp: In function 'll dp(int, int)':
clo.cpp:5:24: warning: statement has no effect [-Wunused-value]
    5 |     #define debug(...) 42
      |                        ^~
clo.cpp:102:5: note: in expansion of macro 'debug'
  102 |     debug(c, o, res);
      |     ^~~~~
#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...