Submission #122815

# Submission time Handle Problem Language Result Execution time Memory
122815 2019-06-29T10:27:10 Z WhipppedCream Two Dishes (JOI19_dishes) C++17
10 / 100
72 ms 16504 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 2e3+5;

int n, m;
ll a[maxn];
ll b[maxn];
ll p[maxn];
ll q[maxn];
ll s[maxn];
ll t[maxn];

int dp[maxn][maxn];

int solve(int x, int y)
{
	if(x == n && y == m) return 0;
	if(dp[x][y] != -1) return dp[x][y];
	int best = -1e9;
	if(x< n) best = max(best, (a[x+1]+b[y]<= s[x+1])+solve(x+1, y));
	if(y< m) best = max(best, (a[x]+b[y+1]<= t[y+1])+solve(x, y+1));
	return dp[x][y] = best;
}

int main()
{
	memset(dp, -1, sizeof dp);
	scanf("%d %d", &n, &m);
	for(int i = 1; i<= n; i++) scanf("%lld %lld %lld", &a[i], &s[i], &p[i]);
	for(int i = 1; i<= m; i++) scanf("%lld %lld %lld", &b[i], &t[i], &q[i]);
	for(int i = 1; i<= n; i++) a[i] += a[i-1];
	for(int i = 1; i<= m; i++) b[i] += b[i-1];
	printf("%d\n", solve(0, 0));
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:36: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:37:34: 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("%lld %lld %lld", &a[i], &s[i], &p[i]);
                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:38:34: 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("%lld %lld %lld", &b[i], &t[i], &q[i]);
                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 20 ms 16120 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 15992 KB Output is correct
2 Correct 16 ms 16120 KB Output is correct
3 Correct 16 ms 15992 KB Output is correct
4 Correct 16 ms 16096 KB Output is correct
5 Correct 16 ms 15992 KB Output is correct
6 Correct 16 ms 16120 KB Output is correct
7 Correct 15 ms 16120 KB Output is correct
8 Correct 14 ms 16120 KB Output is correct
9 Correct 15 ms 16120 KB Output is correct
10 Correct 14 ms 16120 KB Output is correct
11 Correct 15 ms 16092 KB Output is correct
12 Correct 15 ms 16120 KB Output is correct
13 Correct 16 ms 16120 KB Output is correct
14 Correct 15 ms 16120 KB Output is correct
15 Correct 15 ms 16120 KB Output is correct
16 Correct 15 ms 16120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 15992 KB Output is correct
2 Correct 16 ms 16120 KB Output is correct
3 Correct 16 ms 15992 KB Output is correct
4 Correct 16 ms 16096 KB Output is correct
5 Correct 16 ms 15992 KB Output is correct
6 Correct 16 ms 16120 KB Output is correct
7 Correct 15 ms 16120 KB Output is correct
8 Correct 14 ms 16120 KB Output is correct
9 Correct 15 ms 16120 KB Output is correct
10 Correct 14 ms 16120 KB Output is correct
11 Correct 15 ms 16092 KB Output is correct
12 Correct 15 ms 16120 KB Output is correct
13 Correct 16 ms 16120 KB Output is correct
14 Correct 15 ms 16120 KB Output is correct
15 Correct 15 ms 16120 KB Output is correct
16 Correct 15 ms 16120 KB Output is correct
17 Correct 71 ms 16376 KB Output is correct
18 Correct 72 ms 16504 KB Output is correct
19 Correct 72 ms 16476 KB Output is correct
20 Correct 68 ms 16376 KB Output is correct
21 Correct 70 ms 16376 KB Output is correct
22 Correct 71 ms 16376 KB Output is correct
23 Correct 71 ms 16376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 15992 KB Output is correct
2 Correct 16 ms 16120 KB Output is correct
3 Correct 16 ms 15992 KB Output is correct
4 Correct 16 ms 16096 KB Output is correct
5 Correct 16 ms 15992 KB Output is correct
6 Correct 16 ms 16120 KB Output is correct
7 Correct 15 ms 16120 KB Output is correct
8 Correct 14 ms 16120 KB Output is correct
9 Correct 15 ms 16120 KB Output is correct
10 Correct 14 ms 16120 KB Output is correct
11 Correct 15 ms 16092 KB Output is correct
12 Correct 15 ms 16120 KB Output is correct
13 Correct 16 ms 16120 KB Output is correct
14 Correct 15 ms 16120 KB Output is correct
15 Correct 15 ms 16120 KB Output is correct
16 Correct 15 ms 16120 KB Output is correct
17 Correct 71 ms 16376 KB Output is correct
18 Correct 72 ms 16504 KB Output is correct
19 Correct 72 ms 16476 KB Output is correct
20 Correct 68 ms 16376 KB Output is correct
21 Correct 70 ms 16376 KB Output is correct
22 Correct 71 ms 16376 KB Output is correct
23 Correct 71 ms 16376 KB Output is correct
24 Execution timed out 18 ms 16504 KB Time limit exceeded (wall clock)
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 15992 KB Output is correct
2 Correct 16 ms 16120 KB Output is correct
3 Correct 16 ms 15992 KB Output is correct
4 Correct 16 ms 16096 KB Output is correct
5 Correct 16 ms 15992 KB Output is correct
6 Correct 16 ms 16120 KB Output is correct
7 Correct 15 ms 16120 KB Output is correct
8 Correct 14 ms 16120 KB Output is correct
9 Correct 15 ms 16120 KB Output is correct
10 Correct 14 ms 16120 KB Output is correct
11 Correct 15 ms 16092 KB Output is correct
12 Correct 15 ms 16120 KB Output is correct
13 Correct 16 ms 16120 KB Output is correct
14 Correct 15 ms 16120 KB Output is correct
15 Correct 15 ms 16120 KB Output is correct
16 Correct 15 ms 16120 KB Output is correct
17 Correct 71 ms 16376 KB Output is correct
18 Correct 72 ms 16504 KB Output is correct
19 Correct 72 ms 16476 KB Output is correct
20 Correct 68 ms 16376 KB Output is correct
21 Correct 70 ms 16376 KB Output is correct
22 Correct 71 ms 16376 KB Output is correct
23 Correct 71 ms 16376 KB Output is correct
24 Execution timed out 18 ms 16504 KB Time limit exceeded (wall clock)
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 15992 KB Output is correct
2 Correct 16 ms 16120 KB Output is correct
3 Correct 16 ms 15992 KB Output is correct
4 Correct 16 ms 16096 KB Output is correct
5 Correct 16 ms 15992 KB Output is correct
6 Correct 16 ms 16120 KB Output is correct
7 Correct 15 ms 16120 KB Output is correct
8 Correct 14 ms 16120 KB Output is correct
9 Correct 15 ms 16120 KB Output is correct
10 Correct 14 ms 16120 KB Output is correct
11 Correct 15 ms 16092 KB Output is correct
12 Correct 15 ms 16120 KB Output is correct
13 Correct 16 ms 16120 KB Output is correct
14 Correct 15 ms 16120 KB Output is correct
15 Correct 15 ms 16120 KB Output is correct
16 Correct 15 ms 16120 KB Output is correct
17 Correct 71 ms 16376 KB Output is correct
18 Correct 72 ms 16504 KB Output is correct
19 Correct 72 ms 16476 KB Output is correct
20 Correct 68 ms 16376 KB Output is correct
21 Correct 70 ms 16376 KB Output is correct
22 Correct 71 ms 16376 KB Output is correct
23 Correct 71 ms 16376 KB Output is correct
24 Execution timed out 18 ms 16504 KB Time limit exceeded (wall clock)
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 20 ms 16120 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 20 ms 16120 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -