Submission #1091629

#TimeUsernameProblemLanguageResultExecution timeMemory
1091629Zero_OPCloud Computing (CEOI18_clo)C++14
72 / 100
542 ms2152 KiB
#include<bits/stdc++.h> using namespace std; #define sz(v) (int)v.size() #define all(v) begin(v), end(v) #define compact(v) v.erase(unique(all(v)), end(v)) #define dbg(v) "[" #v " = " << (v) << "]" #define file(name) if(fopen(name".inp", "r")) {freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } #define rep(i, l, r) for(int i = (l); i < (r); ++i) using ll = long long; using vi = vector<int>; using vl = vector<long long>; using ld = long double; template<typename T> bool minimize(T& a, const T& b){ if(a > b){ return a = b, true; } return false; } template<typename T> bool maximize(T& a, const T& b){ if(a < b){ return a = b, true; } return false; } template<int dimension, typename T> struct tensor : public vector<tensor<dimension - 1, T>> { static_assert(dimension > 0, "Dimension must be positive !\n"); template<typename... Args> tensor(int n = 0, Args... args) : vector<tensor<dimension - 1, T>> (n, tensor<dimension - 1, T>(args...)) {} }; template<typename T> struct tensor<1, T> : public vector<T> { tensor(int n = 0, T val = T()) : vector<T>(n, val) {} }; const int MAX = 2e3 * 50 + 1; const ll inf = 1e18; struct item{ int need, value, earn; item(int need, int value, int earn) : need(need), value(value), earn(earn) {} bool operator < (const item& o){ return value > o.value; } }; void testcase(){ int n; cin >> n; vector<item> items; while(n--){ int c, f, p; cin >> c >> f >> p; items.push_back(item(c, f, -p)); } int m; cin >> m; while(m--){ int c, f, p; cin >> c >> f >> p; items.push_back(item(-c, f, p)); } sort(all(items)); ll ans = 0; vector<ll> dp(MAX, -inf); dp[0] = 0; for(int i = 0; i < sz(items); ++i){ vector<ll> nw = dp; for(int j = 0; j < MAX; ++j){ int pre = j - items[i].need; if(0 <= pre && pre < MAX){ maximize(nw[j], dp[pre] + items[i].earn); } } swap(nw, dp); } cout << *max_element(all(dp)); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); file("task"); int T = 1; // cin >> T; while(T--){ testcase(); } return 0; }

Compilation message (stderr)

clo.cpp: In function 'void testcase()':
clo.cpp:76:8: warning: unused variable 'ans' [-Wunused-variable]
   76 |     ll ans = 0;
      |        ^~~
clo.cpp: In function 'int main()':
clo.cpp:9:55: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 | #define file(name) if(fopen(name".inp", "r")) {freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:99:5: note: in expansion of macro 'file'
   99 |     file("task");
      |     ^~~~
clo.cpp:9:88: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 | #define file(name) if(fopen(name".inp", "r")) {freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:99:5: note: in expansion of macro 'file'
   99 |     file("task");
      |     ^~~~
#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...