Submission #578919

#TimeUsernameProblemLanguageResultExecution timeMemory
578919mousebeaverTwo Dishes (JOI19_dishes)C++14
0 / 100
228 ms42000 KiB
#define ll long long #define ull unsigned ll #define pli pair<ll, int> #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin>>n>>m; vector<ll> a(n); vector<ll> s(n); vector<ll> p(n); for(int i = 0; i < n; i++) { cin>>a[i]>>s[i]>>p[i]; } vector<ll> b(m); vector<ll> t(m); vector<ll> q(m); for(int i = 0; i < m; i++) { cin>>b[i]>>t[i]>>q[i]; } vector<ll> prea(n); prea[0] = a[0]; for(int i = 1; i < n; i++) { prea[i] = prea[i-1]+a[i]; } vector<ll> preb(m); preb[0] = b[0]; for(int i = 1; i < m; i++) { preb[i] = preb[i-1]+b[i]; } vector<ll> prep(n); prep[0] = p[0]; for(int i = 1; i < n; i++) { prep[i] = prep[i-1]+p[i]; } vector<ll> preq(n); preq[0] = q[0]; for(int i = 1; i < n; i++) { preq[i] = preq[i-1]+q[i]; } ll time = s[0]; set<pli> mtime; //Zeiten aus preb: time, index for(int i = 0; i < m; i++) { mtime.insert({preb[i], i}); } ll output = 0; for(int i = 0; i < n && prea[i] <= time; i++) { ll score = prep[i]; set<pli>::iterator it = mtime.upper_bound({time-prea[i], numeric_limits<int>::max()}); if(it != mtime.begin()) { it--; pli x = *it; score += preq[x.second]; } output = max(output, score); } cout<<output<<"\n"; /*vector<vector<ll>> dp(n+1, vector<ll> (m+1, 0)); for(int i = 0; i <= n; i++) { for(int j = 0; j <= m; j++) { ll time = 0; if(i > 0) { time += prea[i-1]; } if(j > 0) { time += preb[j-1]; } //Dish 1: if(i > 0) { ll score = dp[i-1][j]; if(time <= s[i-1]) { score += p[i-1]; } dp[i][j] = max(dp[i][j], score); } if(j > 0) { ll score = dp[i][j-1]; if(time <= t[j-1]) { score += q[j-1]; } dp[i][j] = max(dp[i][j], score); } } } cout<<dp[n][m]<<"\n";*/ return 0; }
#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...