Submission #578380

#TimeUsernameProblemLanguageResultExecution timeMemory
578380JohannTwo Dishes (JOI19_dishes)C++14
5 / 100
174 ms24160 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define tiii tuple<int,int,int> #define vi vector<int> #define vpii vector<pii> #define vtiii vector<tiii> #define sz(x) (int) (x).size() #define all(x) (x).begin(), (x).end() const int MAXN = 1e6 + 7; ll N,M; ll A[MAXN],B[MAXN],S[MAXN],T[MAXN],P[MAXN],Q[MAXN]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> N >> M; for (int i = 0; i < N; ++i) cin >> A[i] >> S[i] >> P[i]; for (int i = 0; i < M; ++i) cin >> B[i] >> T[i] >> Q[i]; ll sum = 0; ll ans = 0; ll points = 0; int a = 0, b = 0; while (a < N && sum + A[a] <= S[a]) { sum += A[a]; points += P[a]; ++a; } ans = points; while (b < M) { if (sum + B[b] <= T[b]) { sum += B[b]; points += Q[b]; ++b; ans = max(ans, points); } else { if (a > 0) { --a; sum -= A[a]; points -= P[a]; } else { break; } } } cout << ans << "\n"; }
#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...