Submission #981340

#TimeUsernameProblemLanguageResultExecution timeMemory
981340kh0iCloud Computing (CEOI18_clo)C++17
100 / 100
317 ms1628 KiB
#include "bits/stdc++.h" using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) #endif using ll = long long; using pii = pair<int, int>; #define F first #define S second #define sz(x) (int)((x).size()) #define all(x) (x).begin(), (x).end() mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll get_rand(ll l, ll r) { assert(l <= r); return uniform_int_distribution<ll> (l, r)(rng); } void solve(){ int n, m; cin >> n; vector<tuple<ll, bool, ll, ll>> x; for(int i = 1; i <= n; ++i){ int c, f, v; cin >> c >> f >> v; x.emplace_back(f, 1, c, v); } cin >> m; for(int i = 1; i <= m; ++i){ int c, f, v; cin >> c >> f >> v; x.emplace_back(f, 0, c, v); } sort(all(x)); reverse(all(x)); int mx = 20 * 5000; vector<ll> dp(mx + 5, -1e16); dp[0] = 0; for(auto [f, t, c, v] : x){ if(t) for(int i = mx; i - c >= 0; --i) dp[i] = max(dp[i], dp[i - c] - v); else for(int i = 0; i + c <= mx; ++i) dp[i] = max(dp[i], dp[i + c] + v); } cout << *max_element(all(dp)); } int32_t main() { cin.tie(nullptr)->sync_with_stdio(0); #define task "troll" if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int test = 1; // cin >> test; for(int i = 1; i <= test; ++i){ // cout << "Case #" << i << ": "; solve(); } #ifdef LOCAL cerr << "\n[Time]: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n"; #endif return 0; }

Compilation message (stderr)

clo.cpp: In function 'int32_t main()':
clo.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:64:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         freopen(task".out", "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...