Submission #132068

# Submission time Handle Problem Language Result Execution time Memory
132068 2019-07-18T09:24:45 Z SirCeness Two Dishes (JOI19_dishes) C++14
0 / 100
436 ms 57720 KB
#include <bits/stdc++.h>

using namespace std;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define bas(x) #x << ": " << x << " "
#define prarr(x, n) cout << #x << ": "; for (int qsd = 0; qsd < n; qsd++) cout << x[qsd] << " "; cout << endl;
#define prarrv(x) cout << #x << ": "; for (int qsd = 0; qsd < (int)x.size(); qsd++) cout << x[qsd] << " "; cout << endl;
#define inside sl<=l%&&r<=sr
#define outside sr<l||r<sl

typedef long long ll;

struct node {
	ll a, b, top;
	double sirala;
	
	bool operator<(const node& a){
		return sirala < a.sirala;
	}
};

node a[200002];
node b[200002];
vector<node> ab;
int n, m;
int dp[2002][2002];

int main(){
	cin >> n >> m;
	ll cur = 0;
	for (int i = 0; i < n; i++){
		int x, y, c;
		cin >> x >> y >> c;
		cur += x;
		a[i] = {x, y, cur, y};
	}
	cur = 0;
	for (int i = 0; i < m; i++){
		int x, y, c;
		cin >> x >> y >> c;
		cur += x;
		b[i] = {x, y, cur, y};
	}
	
	for (int i = 0; i <= n; i++) 
	for (int j = 0; j <= m; j++)
	dp[i][j] = -1;
	
	dp[0][0] = 0;
	for (int i = 0; i <= n; i++){
		for (int j = 0; j <= m; j++){
			if (i != n) dp[i+1][j] = max(dp[i+1][j], dp[i][j] + ((a[i+1].top + b[j].top <= a[i+1].b) ? 1 : 0));
			if (j != m) dp[i][j+1] = max(dp[i][j+1], dp[i][j] + ((a[i].top + b[j+1].top <= b[j+1].b) ? 1 : 0));
		}
	}
	
	cout << dp[n][m] << endl;
	
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:37:23: warning: narrowing conversion of 'y' from 'int' to 'double' inside { } [-Wnarrowing]
   a[i] = {x, y, cur, y};
                       ^
dishes.cpp:44:23: warning: narrowing conversion of 'y' from 'int' to 'double' inside { } [-Wnarrowing]
   b[i] = {x, y, cur, y};
                       ^
# Verdict Execution time Memory Grader output
1 Runtime error 436 ms 57720 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 436 ms 57720 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 436 ms 57720 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -