Submission #860765

#TimeUsernameProblemLanguageResultExecution timeMemory
860765browntoadTwo Dishes (JOI19_dishes)C++14
10 / 100
1448 ms96984 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define int ll #define pii pair<int, int> #define ppi pair<pii, int> #define pip pair<int, pii> #define pb push_back #define ALL(x) (x).begin(), (x).end() #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define REP1(i, n) FOR(i, 1, n+1) #define RREP(i, n) for (int i = (n)-1; i >= 0; i--) #define SZ(x) (int)((x).size()) const ll maxn = 2005; const ll inf = (1ll<<60); const ll mod = 1e9+7; int n, m; int dp[maxn][maxn]; signed main(){ ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin>>n>>m; vector<int> a(n+1), s(n+1), p(n+1); vector<int> b(m+1), t(m+1), q(m+1); REP1(i, n) cin>>a[i]>>s[i]>>p[i]; REP1(j, m) cin>>b[j]>>t[j]>>q[j]; REP1(i, n) a[i] += a[i-1]; REP1(j, m) b[j] += b[j-1]; REP(i, n+1){ REP(j, m+1){ if (i > 0) dp[i][j] = max(dp[i][j], dp[i-1][j] + (a[i]+b[j] <= s[i])); if (j > 0) dp[i][j] = max(dp[i][j], dp[i][j-1] + (a[i]+b[j] <= t[j])); } } cout<<dp[n][m]<<endl; }
#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...