답안 #1069648

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1069648 2024-08-22T07:41:57 Z 김은성(#11131) Two Dishes (JOI19_dishes) C++17
10 / 100
10000 ms 41812 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);
	vector<ll> ppa(n+1), ppb(m+1);
	for(i=1; i<=n; i++){
		scanf("%lld %lld %lld", &ta[i], &sa[i], &pa[i]);
		ta[i] += ta[i-1];
		ppa[i] = ppa[i-1] + pa[i];
	}
	for(i=1; i<=m; i++){
		scanf("%lld %lld %lld", &tb[i], &sb[i], &pb[i]);
		tb[i] += tb[i-1];
		ppb[i] = ppb[i-1] + pb[i];
	}
	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;
		}
	}
	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;
		}
	}
	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:15:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%lld %lld %lld", &ta[i], &sa[i], &pa[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   scanf("%lld %lld %lld", &tb[i], &sb[i], &pb[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10061 ms 41812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 10588 KB Output is correct
4 Correct 1 ms 10588 KB Output is correct
5 Correct 1 ms 10588 KB Output is correct
6 Correct 1 ms 10588 KB Output is correct
7 Correct 1 ms 10684 KB Output is correct
8 Correct 1 ms 10588 KB Output is correct
9 Correct 1 ms 10588 KB Output is correct
10 Correct 1 ms 10588 KB Output is correct
11 Correct 1 ms 10588 KB Output is correct
12 Correct 1 ms 10588 KB Output is correct
13 Correct 1 ms 10588 KB Output is correct
14 Correct 2 ms 10588 KB Output is correct
15 Correct 1 ms 10588 KB Output is correct
16 Correct 1 ms 10680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 10588 KB Output is correct
4 Correct 1 ms 10588 KB Output is correct
5 Correct 1 ms 10588 KB Output is correct
6 Correct 1 ms 10588 KB Output is correct
7 Correct 1 ms 10684 KB Output is correct
8 Correct 1 ms 10588 KB Output is correct
9 Correct 1 ms 10588 KB Output is correct
10 Correct 1 ms 10588 KB Output is correct
11 Correct 1 ms 10588 KB Output is correct
12 Correct 1 ms 10588 KB Output is correct
13 Correct 1 ms 10588 KB Output is correct
14 Correct 2 ms 10588 KB Output is correct
15 Correct 1 ms 10588 KB Output is correct
16 Correct 1 ms 10680 KB Output is correct
17 Correct 11 ms 10908 KB Output is correct
18 Correct 13 ms 10844 KB Output is correct
19 Correct 12 ms 10876 KB Output is correct
20 Correct 11 ms 10844 KB Output is correct
21 Correct 11 ms 10908 KB Output is correct
22 Correct 11 ms 10844 KB Output is correct
23 Correct 11 ms 10792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 10588 KB Output is correct
4 Correct 1 ms 10588 KB Output is correct
5 Correct 1 ms 10588 KB Output is correct
6 Correct 1 ms 10588 KB Output is correct
7 Correct 1 ms 10684 KB Output is correct
8 Correct 1 ms 10588 KB Output is correct
9 Correct 1 ms 10588 KB Output is correct
10 Correct 1 ms 10588 KB Output is correct
11 Correct 1 ms 10588 KB Output is correct
12 Correct 1 ms 10588 KB Output is correct
13 Correct 1 ms 10588 KB Output is correct
14 Correct 2 ms 10588 KB Output is correct
15 Correct 1 ms 10588 KB Output is correct
16 Correct 1 ms 10680 KB Output is correct
17 Correct 11 ms 10908 KB Output is correct
18 Correct 13 ms 10844 KB Output is correct
19 Correct 12 ms 10876 KB Output is correct
20 Correct 11 ms 10844 KB Output is correct
21 Correct 11 ms 10908 KB Output is correct
22 Correct 11 ms 10844 KB Output is correct
23 Correct 11 ms 10792 KB Output is correct
24 Execution timed out 10058 ms 39020 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 10588 KB Output is correct
4 Correct 1 ms 10588 KB Output is correct
5 Correct 1 ms 10588 KB Output is correct
6 Correct 1 ms 10588 KB Output is correct
7 Correct 1 ms 10684 KB Output is correct
8 Correct 1 ms 10588 KB Output is correct
9 Correct 1 ms 10588 KB Output is correct
10 Correct 1 ms 10588 KB Output is correct
11 Correct 1 ms 10588 KB Output is correct
12 Correct 1 ms 10588 KB Output is correct
13 Correct 1 ms 10588 KB Output is correct
14 Correct 2 ms 10588 KB Output is correct
15 Correct 1 ms 10588 KB Output is correct
16 Correct 1 ms 10680 KB Output is correct
17 Correct 11 ms 10908 KB Output is correct
18 Correct 13 ms 10844 KB Output is correct
19 Correct 12 ms 10876 KB Output is correct
20 Correct 11 ms 10844 KB Output is correct
21 Correct 11 ms 10908 KB Output is correct
22 Correct 11 ms 10844 KB Output is correct
23 Correct 11 ms 10792 KB Output is correct
24 Execution timed out 10058 ms 39020 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 10588 KB Output is correct
4 Correct 1 ms 10588 KB Output is correct
5 Correct 1 ms 10588 KB Output is correct
6 Correct 1 ms 10588 KB Output is correct
7 Correct 1 ms 10684 KB Output is correct
8 Correct 1 ms 10588 KB Output is correct
9 Correct 1 ms 10588 KB Output is correct
10 Correct 1 ms 10588 KB Output is correct
11 Correct 1 ms 10588 KB Output is correct
12 Correct 1 ms 10588 KB Output is correct
13 Correct 1 ms 10588 KB Output is correct
14 Correct 2 ms 10588 KB Output is correct
15 Correct 1 ms 10588 KB Output is correct
16 Correct 1 ms 10680 KB Output is correct
17 Correct 11 ms 10908 KB Output is correct
18 Correct 13 ms 10844 KB Output is correct
19 Correct 12 ms 10876 KB Output is correct
20 Correct 11 ms 10844 KB Output is correct
21 Correct 11 ms 10908 KB Output is correct
22 Correct 11 ms 10844 KB Output is correct
23 Correct 11 ms 10792 KB Output is correct
24 Execution timed out 10058 ms 39020 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10061 ms 41812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10061 ms 41812 KB Time limit exceeded
2 Halted 0 ms 0 KB -