# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
105844 | Pro_ktmr | Two Dishes (JOI19_dishes) | C++14 | 271 ms | 30396 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
int N,M;
LL A[1000000],B[1000000],S[1000000],T[1000000],P[1000000],Q[1000000],waA[1000000],waB[1000000],waP[1000000],waQ[1000000];
int main(){
scanf("%d%d", &N, &M);
for(int i=0; i<N; i++) scanf("%lld%lld%lld", A+i, S+i, P+i);
for(int i=0; i<M; i++) scanf("%lld%lld%lld", B+i, T+i, Q+i);
for(int i=0; i<N; i++) waA[i] = (i==0 ? 0 : waA[i-1]) + A[i];
for(int i=0; i<M; i++) waB[i] = (i==0 ? 0 : waB[i-1]) + B[i];
for(int i=0; i<N; i++) waP[i] = (i==0 ? 0 : waP[i-1]) + P[i];
for(int i=0; i<M; i++) waQ[i] = (i==0 ? 0 : waQ[i-1]) + Q[i];
//
int idx = upper_bound(waB, waB+M, S[0]) - waB - 1;
LL ans = waQ[idx];
for(int i=0; i<N; i++){
if(waA[i] > S[0]) continue;
LL nokori = S[0] - waA[i];
idx = upper_bound(waB, waB+M, nokori) - waB - 1;
ans = max(ans, waP[i]+(idx==-1 ? 0 : waQ[idx]));
//cout << i << " " << idx << endl;
}
cout << ans << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |