Submission #861100

#TimeUsernameProblemLanguageResultExecution timeMemory
861100yeediotTwo Dishes (JOI19_dishes)C++14
10 / 100
27 ms32092 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define F first #define S second #define all(x) x.begin(),x.end() #define pii pair<int,int> #define pb push_back #define sz(x) (int)(x.size()) #define chmin(x,y) x=min(x,y) #define chmax(x,y) x=max(x,y) #define vi vector<int> #define vp vector<pii> #define vvi vector<vi> //Don't open the standings during contests. const int mxn=2005; vector<int>a(mxn),s(mxn),p(mxn),b(mxn),t(mxn),q(mxn),pre(mxn),pre2(mxn); signed main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int n,m; cin>>n>>m; for(int i=1;i<=n;i++){ cin>>a[i]>>s[i]>>p[i]; pre[i]=pre[i-1]+a[i]; } for(int i=1;i<=m;i++){ cin>>b[i]>>t[i]>>q[i]; pre2[i]=pre2[i-1]+b[i]; } vector<vector<int>>dp(n+1,vector<int>(m+1,-8e18)); dp[0][0]=0; for(int i=0;i<=n;i++){ for(int j=0;j<=m;j++){ if(i)chmax(dp[i][j],dp[i-1][j]+(pre[i]+pre2[j]<=s[i])*p[i]); if(j)chmax(dp[i][j],dp[i][j-1]+(pre[i]+pre2[j]<=t[j])*q[j]); } } cout<<dp[n][m]<<'\n'; } /* input: */
#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...