Submission #768520

#TimeUsernameProblemLanguageResultExecution timeMemory
768520nguyentunglamTwo Dishes (JOI19_dishes)C++17
10 / 100
29 ms32144 KiB
#include<bits/stdc++.h> #define fi first #define se second #define endl "\n" #define ii pair<int, int> using namespace std; const int N = 2010; long long a[N], b[N], s[N], t[N], p[N], q[N]; long long f[N][N]; int main() { #define task "" cin.tie(0) -> sync_with_stdio(0); if (fopen ("task.inp", "r")) { freopen ("task.inp", "r", stdin); freopen ("task.out", "w", stdout); } if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } int n, m; cin >> n >> m; for(int i = 1; i <= n; i++) { cin >> a[i] >> s[i] >> p[i]; a[i] += a[i - 1]; } for(int i = 1; i <= m; i++) { cin >> b[i] >> t[i] >> q[i]; b[i] += b[i - 1]; } memset(f, -127, sizeof(f)); f[0][0] = 0; for(int i = 0; i <= n; i++) for(int j = 0; j <= m; j++) { if (i == 0 && j == 0) continue; if (i) f[i][j] = max(f[i][j], f[i - 1][j] + (a[i] + b[j] <= s[i]) * p[i]); if (j) f[i][j] = max(f[i][j], f[i][j - 1] + (a[i] + b[j] <= t[j]) * q[j]); } cout << f[n][m]; }

Compilation message (stderr)

dishes.cpp: In function 'int main()':
dishes.cpp:14:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen ("task.inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:15:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen ("task.out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:18:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:19:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...