Submission #108806

# Submission time Handle Problem Language Result Execution time Memory
108806 2019-05-02T08:13:53 Z antimirage Two Dishes (JOI19_dishes) C++14
0 / 100
27 ms 31864 KB
/**
	Elohim Essaim, Elohim Essaim I implore you...
**/
#include <bits/stdc++.h>
 
#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
 
using namespace std;
 
const int N = 2e3 + 5;
 
int n, m, a[N], b[N], p[N], s[N], t[N], q[N], pr1[N], pr2[N];

long long dp[N][N];

main(){
	cin >> n >> m;
	
	for (int i = 1; i <= n; i++){
		
		scanf("%d%d%d", &a[i], &s[i], &p[i]);
		pr1[i] = pr1[i - 1] + a[i];
	}	
	for (int i = 1; i <= m; i++){
		
		scanf("%d%d%d", &b[i], &t[i], &q[i]);
		pr2[i] = pr2[i - 1] + b[i];
	}
	memset(dp, -0x3f3f3f3f, sizeof(dp) );
	dp[0][0] = 0;
	
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= m; j++)
		{
			if (i + 1 <= n){
				if (pr1[i + 1] + pr2[j] <= s[i + 1])
					dp[i + 1][j] = max( dp[i + 1][j], dp[i][j] + p[i + 1] );
				else
					dp[i + 1][j] = max( dp[i + 1][j], dp[i][j] );
			}
			if (j + 1 <= m){
				if (pr1[i] + pr2[j + 1] <= t[j + 1])
					dp[i][j + 1] = max( dp[i][j + 1], dp[i][j] + q[j + 1] );
				else
					dp[i][j + 1] = max( dp[i][j + 1], dp[i][j] );
			}
		}
	}
	cout << dp[n][m] << endl;
}

Compilation message

dishes.cpp:20:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
dishes.cpp: In function 'int main()':
dishes.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &a[i], &s[i], &p[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &b[i], &t[i], &q[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 5 ms 384 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 31864 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 31864 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 31864 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 31864 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 31864 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5 ms 384 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5 ms 384 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -