Submission #123354

# Submission time Handle Problem Language Result Execution time Memory
123354 2019-07-01T08:14:12 Z 임유진(#3021) Two Dishes (JOI19_dishes) C++14
0 / 100
3 ms 376 KB
#include<stdio.h>
#include<algorithm>

using namespace std;

#define MAXN 2005

int A[MAXN], S[MAXN], P[MAXN], B[MAXN], T[MAXN], Q[MAXN];
int dp[MAXN][MAXN];
int suma[MAXN], sumb[MAXN];

int main() {
	int N, M;

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

	for(int i = 1; i <= N; i++) suma[i] = suma[i-1] + A[i];
	for(int i = 1; i <= M; i++) sumb[i] = sumb[i-1] + B[i];

	for(int i = 0; i <= N; i++) for(int j = 0; j <= M; j++) {
		dp[i][j] = 0;
		if(i > 0) dp[i][j] = dp[i-1][j] + (S[i] >= suma[i] + sumb[j] ? 1 : 0);
		if(j > 0) dp[i][j] = max(dp[i][j], dp[i][j-1] + (T[j] >= suma[i] + sumb[j] ? 1 : 0));
	}

	printf("%d", dp[N][M]);
	return 0;
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:15: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:16:35: 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%d%d", A+i, S+i, P+i);
                              ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:17:35: 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%d%d", B+i, T+i, Q+i);
                              ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 3 ms 256 KB Time limit exceeded (wall clock)
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 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -