Submission #152974

#TimeUsernameProblemLanguageResultExecution timeMemory
152974usernameTwo Dishes (JOI19_dishes)C++14
5 / 100
236 ms30456 KiB
#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)

dishes.cpp: In function 'int main()':
dishes.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~
dishes.cpp:12:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<N; i++) scanf("%lld%lld%lld", A+i, S+i, P+i);
                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:13:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<M; i++) scanf("%lld%lld%lld", B+i, T+i, Q+i);
                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...