Submission #374178

#TimeUsernameProblemLanguageResultExecution timeMemory
374178Mamnoon_SiamTwo Dishes (JOI19_dishes)C++17
0 / 100
4 ms876 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; using vi = vector<int>; #define all(v) begin(v), end(v) #define sz(v) (int)(v).size() #define fi first #define se second const int N = 2e3 + 3; int n, m; ll A[N], B[N], S[N], T[N], P[N], Q[N]; ll donburi[N][N], curry[N][N]; ll donburi_p[N][N], curry_p[N][N]; ll dp[N][N]; int main(int argc, char const *argv[]) { #ifdef LOCAL freopen("in", "r", stdin); #endif scanf("%d %d", &n, &m); for(int i = 1; i <= n; ++i) { scanf("%lld %lld %lld", &A[i], &S[i], &P[i]); } for(int i = 1; i <= m; ++i) { scanf("%lld %lld %lld", &B[i], &T[i], &Q[i]); } for(ll i = 1, sum = 0; i <= n; ++i) { sum += A[i]; if(sum <= S[i]) { int j = 0; ll sum2 = 0; while(j < m and sum + sum2 + B[j+1] <= S[i]) { sum2 += B[++j]; } donburi[i][j] = P[i]; } } for(ll i = 1, sum = 0; i <= m; ++i) { sum += B[i]; if(sum <= T[i]) { int j = 0; ll sum2 = 0; while(j < n and sum + sum2 + A[j+1] <= T[i]) { sum2 += B[++j]; } curry[j][i] = Q[i]; } } for(int i = 0; i <= n; ++i) { curry_p[i][0] = curry[i][0]; for(int j = 1; j <= m; ++j) curry_p[i][j] = curry_p[i][j-1] + curry[i][j]; donburi_p[i][m] = donburi[i][m]; for(int j = m-1; j >= 0; --j) { donburi_p[i][j] = donburi_p[i][j+1] + donburi[i][j]; } } function<void(ll&,ll)> chkmax = [](ll& x, ll y) { x = max(x, y); }; for(int x = 0; x <= n; ++x) { for(int y = 0; y <= m; ++y) { chkmax(dp[x+1][y], curry_p[x+1][y] + donburi_p[x+1][y] + dp[x][y]); chkmax(dp[x][y+1], curry[x][y+1] + dp[x][y]); } } printf("%lld\n", dp[n][m]); return 0; } /* * use std::array instead of std::vector, if u can * overflow? * array bounds */

Compilation message (stderr)

dishes.cpp: In function 'int main(int, const char**)':
dishes.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |   scanf("%d %d", &n, &m);
      |   ~~~~~^~~~~~~~~~~~~~~~~
dishes.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |     scanf("%lld %lld %lld", &A[i], &S[i], &P[i]);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |     scanf("%lld %lld %lld", &B[i], &T[i], &Q[i]);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...