Submission #1093129

#TimeUsernameProblemLanguageResultExecution timeMemory
1093129InvMODCloud Computing (CEOI18_clo)C++14
18 / 100
261 ms1884 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e3+1; const ll INF = 1e18; int n, m; int c[N], C[N], F[N], f[N]; ll V[N], v[N]; namespace Sub4{ bool ckSub() { int cnt = 0; for(int i = 1; i <= n; i++) cnt += (f[i] == 1); for(int i = 1; i <= m; i++) cnt += (F[i] == 1); return cnt == (n+m); } vector<ll> f, g; void solve() { int sum_room = 0; for(int i = 1; i <= n; i++){ sum_room = sum_room + c[i]; } f.assign(sum_room+1, INF); sum_room = 0; for(int i = 1; i <= m; i++){ sum_room = sum_room + C[i]; } g.assign(sum_room+1, -INF); f[0] = 0; for(int i = 1; i <= n; i++){ for(int j = (int)f.size()-1; j >= c[i]; j--){ f[j] = min(f[j], f[j-c[i]] + v[i]); } } g[0] = 0; for(int i = 1; i <= m; i++){ for(int j = (int)g.size()-1; j >= C[i]; j--){ g[j] = max(g[j], g[j-C[i]] + V[i]); } } for(int i = (int)f.size()-2; i >= 0; i--){ f[i] = min(f[i], f[i+1]); } ll answer = 0; for(int i = 1; i < min((int) f.size(), (int) g.size()); i++){ answer = max(answer, (g[i] - f[i])); } cout << answer <<"\n"; return; } } void inp() { cin >> n; for(int i = 1; i <= n; i++){ cin >> c[i] >> f[i] >> v[i]; } cin >> m; for(int i = 1; i <= m; i++){ cin >> C[i] >> F[i] >> V[i]; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define name "task" if(fopen(name".INP", "r")){ freopen(name".INP", "r", stdin); freopen(name".OUT", "w", stdout); } inp(); if(Sub4::ckSub()){ Sub4::solve(); } return 0; }

Compilation message (stderr)

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