Submission #1264397

#TimeUsernameProblemLanguageResultExecution timeMemory
1264397minggaCloud Computing (CEOI18_clo)C++20
0 / 100
2 ms1864 KiB
// Author: caption_mingle #include "bits/stdc++.h" using namespace std; #define ln "\n" #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define ll long long const int mod = 1e9 + 7; const int inf = 2e9; const int N = 4005; const int M = 1e5 + 7; int n, m; ll dp[2][M]; struct dak { int c, f, v; bool operator < (const dak& o) const { if(f == o.f) return v < o.v; return f > o.f; } } a[N]; signed main() { cin.tie(0) -> sync_with_stdio(0); #define task "" if(fopen(task ".INP", "r")) { freopen(task ".INP", "r", stdin); freopen(task ".OUT", "w", stdout); } cin >> n; int totc = 0; for(int i = 1; i <= n; i++) { int c, f, v; cin >> c >> f >> v; a[i] = {c, f, -v}; totc += c; } cin >> m; for(int i = 1; i <= m; i++) { int c, f, v; cin >> c >> f >> v; a[i + n] = {-c, f, v}; } n += m; sort(a + 1, a + n + 1); memset(dp, -0x3f, sizeof dp); dp[0][0] = 0; // for(int i = 1; i <= n; i++) { // cerr << a[i].c << ' ' << a[i].f << ' ' << a[i].v << ln; // } for(int i = 1; i <= n; i++) { int id = i & 1; for(int j = 0; j <= totc; j++) { dp[id][j] = dp[id ^ 1][j]; } for(int j = 0; j <= totc; j++) { int nc = j + a[i].c; if(nc >= 0) dp[id][nc] = max(dp[id][nc], dp[id ^ 1][j] + a[i].v); } // for(int j = 0; j <= totc; j++) // cerr << i << ' ' << j << ' ' << dp[id][j] << ln; } cout << * max_element(dp[n & 1] + 1, dp[n & 1] + n + 1) << ln; cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC; }

Compilation message (stderr)

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