Submission #152970

#TimeUsernameProblemLanguageResultExecution timeMemory
152970usernameTwo Dishes (JOI19_dishes)C++14
10 / 100
73 ms16504 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC target ("sse4") using namespace std; #define X first #define Y second #define pb push_back typedef pair<int, int> ii; typedef long long ll; const int maxn = 2e3+5; int n, m; ll a[maxn]; ll b[maxn]; ll p[maxn]; ll q[maxn]; ll s[maxn]; ll t[maxn]; int dp[maxn][maxn]; int solve(int x, int y) { if(x == n && y == m) return 0; if(dp[x][y] != -1) return dp[x][y]; int best = -1e9; if(x< n) best = max(best, (a[x+1]+b[y]<= s[x+1])+solve(x+1, y)); if(y< m) best = max(best, (a[x]+b[y+1]<= t[y+1])+solve(x, y+1)); return dp[x][y] = best; } int main() { memset(dp, -1, sizeof dp); 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(int i = 1; i<= n; i++) a[i] += a[i-1]; for(int i = 1; i<= m; i++) b[i] += b[i-1]; printf("%d\n", solve(0, 0)); }

Compilation message (stderr)

dishes.cpp: In function 'int main()':
dishes.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
dishes.cpp:37:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i<= n; i++) scanf("%lld %lld %lld", &a[i], &s[i], &p[i]);
                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:38:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i<= m; i++) 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...