Submission #1099597

#TimeUsernameProblemLanguageResultExecution timeMemory
1099597ortsacCloud Computing (CEOI18_clo)C++17
100 / 100
748 ms2392 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int MAXS = 1e5; const int INF = 0x3f3f3f3f3f3f3f3f; struct O { int c, f, v; bool t; O(int a = 0, int b = 0, int x = 0, bool d = 0) : c(a), f(b), v(x), t(d) {} bool operator < (const O& a) { return (make_pair(f, t) < make_pair(a.f, a.t)); } }; int ant[MAXS + 10], at[MAXS + 10]; int32_t main() { int n, m; vector<O> orders; cin >> n; for (int i = 0; i < n; i++) { int c, f, v; cin >> c >> f >> v; orders.push_back(O(c, f, v, 1)); } cin >> m; for (int i = 0; i < m; i++) { int c, f, v; cin >> c >> f >> v; orders.push_back(O(c, f, v, 0)); } sort(orders.begin(), orders.end()); //for (int i = 0; i <= MAXS; i++) ant[i] = -INF; //ant[0] = 0; int ans = 0; for (int i = 0; i < (n + m); i++) { auto u = orders[i]; //cout << u.c << " " << u.f << " " << u.v << " " << u.t << "\n"; for (int j = 0; j <= MAXS; j++) { at[j] = ant[j]; if (u.t) { // comprar pc if ((j + u.c) <= MAXS) { at[j] = max(at[j], ant[j + u.c] - u.v); } } else { if ((j - u.c) >= 0LL) { at[j] = max(at[j], ant[j - u.c] + u.v); } } //if (at[j] > ans) cout << i << " " << j << "\n"; //ans = max(ans, at[j]); } swap(at, ant); } cout << ant[0] << "\n"; }

Compilation message (stderr)

clo.cpp: In function 'int32_t main()':
clo.cpp:39:9: warning: unused variable 'ans' [-Wunused-variable]
   39 |     int ans = 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...