답안 #796214

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
796214 2023-07-28T08:02:43 Z Dan4Life Two Dishes (JOI19_dishes) C++17
15 / 100
137 ms 47668 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mxN = (int)1e6+10;
const int LINF = (int)2e18;
int n, m;
int a[2][mxN], s[2][mxN], p[2][mxN], pr[2][mxN], pr2[2][mxN];

int32_t main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m; int ans = -LINF;
	for(int j : {0,1}){
		for(int i = 1; i <= n; i++){
			cin >> a[j][i] >> s[j][i] >> p[j][i];
			pr[j][i]=pr[j][i-1]+a[j][i];
			pr2[j][i]=pr2[j][i-1]+p[j][i];
		}
		swap(n,m);
	}
	if(max(n,m)<=3000){
		int dp[2010][2010];
		for(int i = 0; i <= n; i++)
		for(int j = 0; j <= m; j++)
			dp[i][j] = !!(i|j)*-LINF;
		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= m; j++){
				int tim = pr[0][i]+pr[1][j];
				if(i) dp[i][j] = max(dp[i][j],dp[i-1][j]+(tim<=s[0][i])*p[0][i]);
				if(j) dp[i][j] = max(dp[i][j],dp[i][j-1]+(tim<=s[1][j])*p[1][j]);
			}
		}
		cout << dp[n][m] << "\n"; return 0;
	}
	for(int j : {0,1}){
		for(int i = 0; i <= n; i++){
			if(pr[j][i]>s[j][1]) break;
			int l = 0, r = m;
			while(l<r){
				int mid = (l+r+1)/2;
				if(pr[j^1][mid]+pr[j][i]<=s[j][1])l=mid;
				else r=mid-1;
			}
			ans = max(ans, pr2[j][i]+pr2[j^1][l]);
		}
		swap(n,m);
	}
	cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 137 ms 47548 KB Output is correct
2 Correct 131 ms 47416 KB Output is correct
3 Correct 122 ms 47588 KB Output is correct
4 Correct 124 ms 47376 KB Output is correct
5 Correct 12 ms 31956 KB Output is correct
6 Correct 124 ms 46880 KB Output is correct
7 Correct 62 ms 39760 KB Output is correct
8 Correct 64 ms 39820 KB Output is correct
9 Correct 121 ms 47600 KB Output is correct
10 Correct 103 ms 47668 KB Output is correct
11 Correct 89 ms 47592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 31996 KB Output is correct
2 Correct 11 ms 32012 KB Output is correct
3 Correct 12 ms 31988 KB Output is correct
4 Correct 12 ms 31976 KB Output is correct
5 Correct 12 ms 31920 KB Output is correct
6 Correct 13 ms 31956 KB Output is correct
7 Correct 12 ms 31956 KB Output is correct
8 Correct 11 ms 31924 KB Output is correct
9 Correct 12 ms 31956 KB Output is correct
10 Correct 12 ms 31956 KB Output is correct
11 Correct 12 ms 31996 KB Output is correct
12 Correct 12 ms 31984 KB Output is correct
13 Correct 12 ms 31952 KB Output is correct
14 Correct 13 ms 32000 KB Output is correct
15 Correct 12 ms 31972 KB Output is correct
16 Correct 16 ms 31968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 31996 KB Output is correct
2 Correct 11 ms 32012 KB Output is correct
3 Correct 12 ms 31988 KB Output is correct
4 Correct 12 ms 31976 KB Output is correct
5 Correct 12 ms 31920 KB Output is correct
6 Correct 13 ms 31956 KB Output is correct
7 Correct 12 ms 31956 KB Output is correct
8 Correct 11 ms 31924 KB Output is correct
9 Correct 12 ms 31956 KB Output is correct
10 Correct 12 ms 31956 KB Output is correct
11 Correct 12 ms 31996 KB Output is correct
12 Correct 12 ms 31984 KB Output is correct
13 Correct 12 ms 31952 KB Output is correct
14 Correct 13 ms 32000 KB Output is correct
15 Correct 12 ms 31972 KB Output is correct
16 Correct 16 ms 31968 KB Output is correct
17 Correct 30 ms 32096 KB Output is correct
18 Correct 29 ms 32080 KB Output is correct
19 Correct 30 ms 32164 KB Output is correct
20 Correct 30 ms 32172 KB Output is correct
21 Correct 30 ms 32156 KB Output is correct
22 Correct 30 ms 32084 KB Output is correct
23 Correct 30 ms 32084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 31996 KB Output is correct
2 Correct 11 ms 32012 KB Output is correct
3 Correct 12 ms 31988 KB Output is correct
4 Correct 12 ms 31976 KB Output is correct
5 Correct 12 ms 31920 KB Output is correct
6 Correct 13 ms 31956 KB Output is correct
7 Correct 12 ms 31956 KB Output is correct
8 Correct 11 ms 31924 KB Output is correct
9 Correct 12 ms 31956 KB Output is correct
10 Correct 12 ms 31956 KB Output is correct
11 Correct 12 ms 31996 KB Output is correct
12 Correct 12 ms 31984 KB Output is correct
13 Correct 12 ms 31952 KB Output is correct
14 Correct 13 ms 32000 KB Output is correct
15 Correct 12 ms 31972 KB Output is correct
16 Correct 16 ms 31968 KB Output is correct
17 Correct 30 ms 32096 KB Output is correct
18 Correct 29 ms 32080 KB Output is correct
19 Correct 30 ms 32164 KB Output is correct
20 Correct 30 ms 32172 KB Output is correct
21 Correct 30 ms 32156 KB Output is correct
22 Correct 30 ms 32084 KB Output is correct
23 Correct 30 ms 32084 KB Output is correct
24 Incorrect 102 ms 47644 KB Output isn't correct
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 31996 KB Output is correct
2 Correct 11 ms 32012 KB Output is correct
3 Correct 12 ms 31988 KB Output is correct
4 Correct 12 ms 31976 KB Output is correct
5 Correct 12 ms 31920 KB Output is correct
6 Correct 13 ms 31956 KB Output is correct
7 Correct 12 ms 31956 KB Output is correct
8 Correct 11 ms 31924 KB Output is correct
9 Correct 12 ms 31956 KB Output is correct
10 Correct 12 ms 31956 KB Output is correct
11 Correct 12 ms 31996 KB Output is correct
12 Correct 12 ms 31984 KB Output is correct
13 Correct 12 ms 31952 KB Output is correct
14 Correct 13 ms 32000 KB Output is correct
15 Correct 12 ms 31972 KB Output is correct
16 Correct 16 ms 31968 KB Output is correct
17 Correct 30 ms 32096 KB Output is correct
18 Correct 29 ms 32080 KB Output is correct
19 Correct 30 ms 32164 KB Output is correct
20 Correct 30 ms 32172 KB Output is correct
21 Correct 30 ms 32156 KB Output is correct
22 Correct 30 ms 32084 KB Output is correct
23 Correct 30 ms 32084 KB Output is correct
24 Incorrect 102 ms 47644 KB Output isn't correct
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 31996 KB Output is correct
2 Correct 11 ms 32012 KB Output is correct
3 Correct 12 ms 31988 KB Output is correct
4 Correct 12 ms 31976 KB Output is correct
5 Correct 12 ms 31920 KB Output is correct
6 Correct 13 ms 31956 KB Output is correct
7 Correct 12 ms 31956 KB Output is correct
8 Correct 11 ms 31924 KB Output is correct
9 Correct 12 ms 31956 KB Output is correct
10 Correct 12 ms 31956 KB Output is correct
11 Correct 12 ms 31996 KB Output is correct
12 Correct 12 ms 31984 KB Output is correct
13 Correct 12 ms 31952 KB Output is correct
14 Correct 13 ms 32000 KB Output is correct
15 Correct 12 ms 31972 KB Output is correct
16 Correct 16 ms 31968 KB Output is correct
17 Correct 30 ms 32096 KB Output is correct
18 Correct 29 ms 32080 KB Output is correct
19 Correct 30 ms 32164 KB Output is correct
20 Correct 30 ms 32172 KB Output is correct
21 Correct 30 ms 32156 KB Output is correct
22 Correct 30 ms 32084 KB Output is correct
23 Correct 30 ms 32084 KB Output is correct
24 Incorrect 102 ms 47644 KB Output isn't correct
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 137 ms 47548 KB Output is correct
2 Correct 131 ms 47416 KB Output is correct
3 Correct 122 ms 47588 KB Output is correct
4 Correct 124 ms 47376 KB Output is correct
5 Correct 12 ms 31956 KB Output is correct
6 Correct 124 ms 46880 KB Output is correct
7 Correct 62 ms 39760 KB Output is correct
8 Correct 64 ms 39820 KB Output is correct
9 Correct 121 ms 47600 KB Output is correct
10 Correct 103 ms 47668 KB Output is correct
11 Correct 89 ms 47592 KB Output is correct
12 Correct 12 ms 31996 KB Output is correct
13 Correct 11 ms 32012 KB Output is correct
14 Correct 12 ms 31988 KB Output is correct
15 Correct 12 ms 31976 KB Output is correct
16 Correct 12 ms 31920 KB Output is correct
17 Correct 13 ms 31956 KB Output is correct
18 Correct 12 ms 31956 KB Output is correct
19 Correct 11 ms 31924 KB Output is correct
20 Correct 12 ms 31956 KB Output is correct
21 Correct 12 ms 31956 KB Output is correct
22 Correct 12 ms 31996 KB Output is correct
23 Correct 12 ms 31984 KB Output is correct
24 Correct 12 ms 31952 KB Output is correct
25 Correct 13 ms 32000 KB Output is correct
26 Correct 12 ms 31972 KB Output is correct
27 Correct 16 ms 31968 KB Output is correct
28 Correct 30 ms 32096 KB Output is correct
29 Correct 29 ms 32080 KB Output is correct
30 Correct 30 ms 32164 KB Output is correct
31 Correct 30 ms 32172 KB Output is correct
32 Correct 30 ms 32156 KB Output is correct
33 Correct 30 ms 32084 KB Output is correct
34 Correct 30 ms 32084 KB Output is correct
35 Incorrect 102 ms 47644 KB Output isn't correct
36 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 137 ms 47548 KB Output is correct
2 Correct 131 ms 47416 KB Output is correct
3 Correct 122 ms 47588 KB Output is correct
4 Correct 124 ms 47376 KB Output is correct
5 Correct 12 ms 31956 KB Output is correct
6 Correct 124 ms 46880 KB Output is correct
7 Correct 62 ms 39760 KB Output is correct
8 Correct 64 ms 39820 KB Output is correct
9 Correct 121 ms 47600 KB Output is correct
10 Correct 103 ms 47668 KB Output is correct
11 Correct 89 ms 47592 KB Output is correct
12 Correct 12 ms 31996 KB Output is correct
13 Correct 11 ms 32012 KB Output is correct
14 Correct 12 ms 31988 KB Output is correct
15 Correct 12 ms 31976 KB Output is correct
16 Correct 12 ms 31920 KB Output is correct
17 Correct 13 ms 31956 KB Output is correct
18 Correct 12 ms 31956 KB Output is correct
19 Correct 11 ms 31924 KB Output is correct
20 Correct 12 ms 31956 KB Output is correct
21 Correct 12 ms 31956 KB Output is correct
22 Correct 12 ms 31996 KB Output is correct
23 Correct 12 ms 31984 KB Output is correct
24 Correct 12 ms 31952 KB Output is correct
25 Correct 13 ms 32000 KB Output is correct
26 Correct 12 ms 31972 KB Output is correct
27 Correct 16 ms 31968 KB Output is correct
28 Correct 30 ms 32096 KB Output is correct
29 Correct 29 ms 32080 KB Output is correct
30 Correct 30 ms 32164 KB Output is correct
31 Correct 30 ms 32172 KB Output is correct
32 Correct 30 ms 32156 KB Output is correct
33 Correct 30 ms 32084 KB Output is correct
34 Correct 30 ms 32084 KB Output is correct
35 Incorrect 102 ms 47644 KB Output isn't correct
36 Halted 0 ms 0 KB -