Submission #1268351

#TimeUsernameProblemLanguageResultExecution timeMemory
1268351longggggCloud Computing (CEOI18_clo)C++17
100 / 100
294 ms1352 KiB
#include <bits/stdc++.h> using namespace std; //====== BITWISE ======// #define MASK(i) (1LL << (i)) #define BIT(x, i) (((x) >> (i)) & 1) #define ON(x, i) ((x) | MASK(i)) #define OFF(x, i) ((x) & ~MASK(i)) #define LASTBIT(mask) ((mask) & -(mask)) #define SUBMASK(sub, mask) for (int sub = (mask); sub >= 1; sub = (sub - 1) & (mask)) //====== OTHER ======// #define fi first #define se second #define ll long long #define endl '\n' #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define mod(x, k) ((((x) % (k)) + (k)) % (k)) #define compress(c) sort(all(c)); c.erase(unique(all(c)), c.end()); #define Longgggg ios_base::sync_with_stdio(0); cin.tie(0); #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define FORD(i, a, b) for (int i = (a); i >= (b); --i) //====== FILE ======// #define IN "A.in" #define OUT "A.out" #define DEBUG "debug.out" //==================// const int INF = (int) 1e9+5; const ll LINF = (ll) 1e18; const ll MOD = (ll) 1e9+7; const int mxN = (int) 1e5+5; struct Computer { int c, f, v, op; }; bool cmp(Computer &a, Computer &b) { if (a.f == b.f) return a.op < b.op; return a.f > b.f; } void solve() { int n; cin >> n; vector <Computer> a; FOR(i, 1, n) { int c, f, v; cin >> c >> f >> v; a.push_back({c, f, v, 0}); } int m; cin >> m; FOR(i, 1, m) { int c, f, v; cin >> c >> f >> v; a.push_back({c, f, v, 1}); } sort(all(a), cmp); vector <ll> dp(mxN+1, -LINF); dp[0] = 0; for (auto &x : a) { int c = x.c, f = x.f, v = x.v; // Them core if (x.op == 0) { FORD(i, mxN, c) if (dp[i-c] != -LINF) dp[i] = max(dp[i], dp[i-c] - v); } // Su dung core else { FOR(i, 0, mxN-c) if (dp[i+c] != -LINF) dp[i] = max(dp[i], dp[i+c] + v); } } cout << *max_element(all(dp)) << endl; } signed main() { if (fopen(IN, "r")) { freopen(IN, "r", stdin); freopen(OUT, "w", stdout); freopen(DEBUG, "w", stderr); } Longgggg ll t = 1; // cin >> t; while (t--) solve(); return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:79:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |         freopen(IN, "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~
clo.cpp:80:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |         freopen(OUT, "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~
clo.cpp:81:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   81 |         freopen(DEBUG, "w", stderr);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
#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...