답안 #123310

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
123310 2019-07-01T06:56:21 Z 김세빈(#3018) Two Dishes (JOI19_dishes) C++14
10 / 100
56 ms 32120 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll A[2020], S[2020], P1[2020], P2[2020];
ll B[2020], T[2020], Q1[2020], Q2[2020];
ll D[2020][2020];
ll n, m, ans;

int main()
{
	ll i, j;
	
	scanf("%lld%lld", &n, &m);
	
	
	for(i=1; i<=n; i++){
		scanf("%lld%lld%lld", A + i, S + i, P1 + i);
		A[i] += A[i - 1];
		if(P1[i] < 0){
			ans += P1[i];
			P2[i] = -P1[i], P1[i] = 0;
		}
	}
	
	for(i=1; i<=m; i++){
		scanf("%lld%lld%lld", B + i, T + i, Q1 + i);
		B[i] += B[i - 1];
		if(Q1[i] < 0){
			ans += Q1[i];
			Q2[i] = -Q1[i], Q1[i] = 0;
		}
	}
	
	for(i=1; i<=n; i++){
		S[i] = upper_bound(B, B + m + 1, S[i] - A[i]) - B;
	}
	
	for(i=1; i<=m; i++){
		T[i] = upper_bound(A, A + n + 1, T[i] - B[i]) - A;
	}
	
	for(i=0; i<=n; i++){
		for(j=0; j<=m; j++){
			if(i || j) D[i][j] = -1e18;
			if(j) D[i][j] = max(D[i][j], D[i][j - 1] + (i < T[j] ? Q1[j] : Q2[j]));
			if(i) D[i][j] = max(D[i][j], D[i - 1][j] + (j < S[i] ? P1[i] : P2[i]));
//			printf("%lld ", D[i][j]);
		}
//		printf("\n");
	}
	
	printf("%lld\n", D[n][m] + ans);
	
	return 0;
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
dishes.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld%lld", A + i, S + i, P1 + i);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld%lld", B + i, T + i, Q1 + i);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 404 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 404 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 56 ms 32016 KB Output is correct
18 Correct 55 ms 32028 KB Output is correct
19 Correct 56 ms 31992 KB Output is correct
20 Correct 53 ms 32000 KB Output is correct
21 Correct 53 ms 30840 KB Output is correct
22 Correct 55 ms 32120 KB Output is correct
23 Correct 55 ms 31992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 404 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 56 ms 32016 KB Output is correct
18 Correct 55 ms 32028 KB Output is correct
19 Correct 56 ms 31992 KB Output is correct
20 Correct 53 ms 32000 KB Output is correct
21 Correct 53 ms 30840 KB Output is correct
22 Correct 55 ms 32120 KB Output is correct
23 Correct 55 ms 31992 KB Output is correct
24 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 404 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 56 ms 32016 KB Output is correct
18 Correct 55 ms 32028 KB Output is correct
19 Correct 56 ms 31992 KB Output is correct
20 Correct 53 ms 32000 KB Output is correct
21 Correct 53 ms 30840 KB Output is correct
22 Correct 55 ms 32120 KB Output is correct
23 Correct 55 ms 31992 KB Output is correct
24 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 404 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 56 ms 32016 KB Output is correct
18 Correct 55 ms 32028 KB Output is correct
19 Correct 56 ms 31992 KB Output is correct
20 Correct 53 ms 32000 KB Output is correct
21 Correct 53 ms 30840 KB Output is correct
22 Correct 55 ms 32120 KB Output is correct
23 Correct 55 ms 31992 KB Output is correct
24 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4 ms 376 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -