Submission #1069566

# Submission time Handle Problem Language Result Execution time Memory
1069566 2024-08-22T06:01:06 Z 김은성(#11131) Two Dishes (JOI19_dishes) C++17
10 / 100
10000 ms 27732 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1000009;
const ll INF = 1.557e18;
int ka[MAXN], kb[MAXN];
ll pa[MAXN], pb[MAXN];
ll dp[2][MAXN];
int main(){
	int n, m, i, j;
	scanf("%d %d", &n, &m);
	vector<ll> ta(n+1), sa(n+1), tb(m+1), sb(m+1);
	for(i=1; i<=n; i++){
		scanf("%lld %lld %lld", &ta[i], &sa[i], &pa[i]);
		ta[i] += ta[i-1];
	}
	for(i=1; i<=m; i++){
		scanf("%lld %lld %lld", &tb[i], &sb[i], &pb[i]);
		tb[i] += tb[i-1];
	}
	for(i=1; i<=n; i++){
		if(sa[i] < ta[i])
			pa[i] = 0;
		else
			ka[i] = upper_bound(tb.begin(), tb.end(), sa[i] - ta[i]) - tb.begin() - 1;
		//printf("pa[%d]=%d ka[%d]=%d\n", i, pa[i], i, ka[i]);
	}
	for(i=1; i<=m; i++){
		if(sb[i] < tb[i])
			pb[i] = 0;
		else
			kb[i] = upper_bound(ta.begin(), ta.end(), sb[i] - tb[i]) - ta.begin() - 1;
		//printf("pb[%d]=%d kb[%d]=%d\n", i, pb[i], i, kb[i]);
	}
	dp[0][0] = 0;
	for(i=0; i<=n; i++){
		for(j=(int)(i==0); j<=m; j++){
			dp[i%2][j] = -INF;
			if(i > 0)
				dp[i%2][j] = max(dp[(i-1)%2][j] + pa[i] * (int)(ka[i] >= j), dp[i%2][j]);
			if(j>0)
				dp[i%2][j] = max(dp[i%2][j-1] + pb[j] * (int)(kb[j] >= i), dp[i%2][j]);
			//printf("dp[%d][%d]=%lld\n", i, j, dp[i%2][j]);
		}
	}
	printf("%lld\n", dp[n%2][m]);
	return 0;
}

Compilation message

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]
   11 |  scanf("%d %d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~
dishes.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%lld %lld %lld", &ta[i], &sa[i], &pa[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf("%lld %lld %lld", &tb[i], &sb[i], &pb[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 10013 ms 27732 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 11 ms 620 KB Output is correct
18 Correct 10 ms 604 KB Output is correct
19 Correct 11 ms 604 KB Output is correct
20 Correct 10 ms 600 KB Output is correct
21 Correct 11 ms 760 KB Output is correct
22 Correct 11 ms 660 KB Output is correct
23 Correct 10 ms 564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 11 ms 620 KB Output is correct
18 Correct 10 ms 604 KB Output is correct
19 Correct 11 ms 604 KB Output is correct
20 Correct 10 ms 600 KB Output is correct
21 Correct 11 ms 760 KB Output is correct
22 Correct 11 ms 660 KB Output is correct
23 Correct 10 ms 564 KB Output is correct
24 Execution timed out 10011 ms 24912 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 11 ms 620 KB Output is correct
18 Correct 10 ms 604 KB Output is correct
19 Correct 11 ms 604 KB Output is correct
20 Correct 10 ms 600 KB Output is correct
21 Correct 11 ms 760 KB Output is correct
22 Correct 11 ms 660 KB Output is correct
23 Correct 10 ms 564 KB Output is correct
24 Execution timed out 10011 ms 24912 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 11 ms 620 KB Output is correct
18 Correct 10 ms 604 KB Output is correct
19 Correct 11 ms 604 KB Output is correct
20 Correct 10 ms 600 KB Output is correct
21 Correct 11 ms 760 KB Output is correct
22 Correct 11 ms 660 KB Output is correct
23 Correct 10 ms 564 KB Output is correct
24 Execution timed out 10011 ms 24912 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10013 ms 27732 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10013 ms 27732 KB Time limit exceeded
2 Halted 0 ms 0 KB -