Submission #123279

# Submission time Handle Problem Language Result Execution time Memory
123279 2019-07-01T05:34:42 Z 이온조(#3019) Two Dishes (JOI19_dishes) C++14
0 / 100
225 ms 23568 KB
#include <bits/stdc++.h>
using namespace std;

const long long INF = 1LL * 1e18;
int A[1000009], B[1000009], P[1000009], Q[1000009];
long long S[1000009], T[1000009], PB[1000009], PQ[1000009];

int main() {
	int N, M; scanf("%d%d",&N,&M);
	for(int i=1; i<=N; i++) scanf("%d%lld%d", &A[i], &S[i], &P[i]);
	for(int i=1; i<=M; i++) scanf("%d%lld%d", &B[i], &T[i], &Q[i]);

	bool S1 = (S[1] == T[1]);
	for(int i=2; i<=N; i++) if(S[i] != S[i-1]) S1 = 0;
	for(int i=2; i<=M; i++) if(T[i] != T[i-1]) S1 = 0;
	if(S1) {
		for(int i=1; i<=M; i++) PB[i] = PB[i-1] + B[i], PQ[i] = PQ[i-1] + Q[i];
		long long x = S[1], ans = -INF, s = 0;
		for(int i=1; i<=N+1; i++) {
			int l = 0, r = M;
			while(l <= r) {
				int m = l+r >> 1;
				if(PB[m] <= x) l = m+1;
				else r = m-1;
			}
			ans = max(ans, s + PQ[l-1]);

			if(i == N+1) break;
			x -= A[i]; s += P[i];
		}
		printf("%lld", ans);
	}
	return 0;
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:22:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int m = l+r >> 1;
             ~^~
dishes.cpp:9:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int N, M; scanf("%d%d",&N,&M);
            ~~~~~^~~~~~~~~~~~~~
dishes.cpp:10:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1; i<=N; i++) scanf("%d%lld%d", &A[i], &S[i], &P[i]);
                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:11:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1; i<=M; i++) scanf("%d%lld%d", &B[i], &T[i], &Q[i]);
                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 224 ms 23032 KB Output is correct
2 Correct 225 ms 23568 KB Output is correct
3 Correct 215 ms 23248 KB Output is correct
4 Correct 219 ms 23416 KB Output is correct
5 Incorrect 2 ms 380 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 224 ms 23032 KB Output is correct
2 Correct 225 ms 23568 KB Output is correct
3 Correct 215 ms 23248 KB Output is correct
4 Correct 219 ms 23416 KB Output is correct
5 Incorrect 2 ms 380 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 224 ms 23032 KB Output is correct
2 Correct 225 ms 23568 KB Output is correct
3 Correct 215 ms 23248 KB Output is correct
4 Correct 219 ms 23416 KB Output is correct
5 Incorrect 2 ms 380 KB Output isn't correct
6 Halted 0 ms 0 KB -