Submission #132146

# Submission time Handle Problem Language Result Execution time Memory
132146 2019-07-18T10:54:50 Z hamzqq9 Two Dishes (JOI19_dishes) C++14
10 / 100
207 ms 32040 KB
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ii pair<int,int>
#define ll long long
#define orta ((bas+son)>>1)
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define umin(x,y) x=min(x,y)
#define umax(x,y) x=max(x,y)
#define inf 1000000000
#define N 200005
#define MOD 998244353
#define KOK 700		
using namespace std;

int n,m;
ll p[N],a[N],s[N],b[N],t[N],q[N];
ll p1[N],p2[N];

int main() {

	scanf("%d %d",&n,&m);

	for(int i=1;i<=n;i++) {

		scanf("%lld %lld %lld",a+i,s+i,p+i);

		p1[i]=p1[i-1]+a[i];

	}

	for(int i=1;i<=m;i++) {

		scanf("%lld %lld %lld",b+i,t+i,q+i);
		
		p2[i]=p2[i-1]+b[i];

	}

	if(n*m<=10000000) {

		vector<vector<ll>> dp;

		dp=vector<vector<ll>>(n+1,vector<ll>(m+1,0));

		for(int i=0;i<=n;i++) {

			for(int j=0;j<=m;j++) {

				if(i) umax(dp[i][j],dp[i-1][j]+((p1[i]+p2[j])<=s[i])*p[i]);
				if(j) umax(dp[i][j],dp[i][j-1]+((p1[i]+p2[j])<=t[j])*q[j]);

			}

		}

		printf("%lld\n",dp[n][m]);
	
		return 0;

	}
 
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
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",a+i,s+i,p+i);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:37: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,q+i);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 207 ms 16220 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 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 376 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
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 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 376 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 68 ms 32040 KB Output is correct
18 Correct 62 ms 31992 KB Output is correct
19 Correct 64 ms 32020 KB Output is correct
20 Correct 58 ms 29632 KB Output is correct
21 Correct 59 ms 30840 KB Output is correct
22 Correct 61 ms 31864 KB Output is correct
23 Correct 67 ms 31864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 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 376 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 68 ms 32040 KB Output is correct
18 Correct 62 ms 31992 KB Output is correct
19 Correct 64 ms 32020 KB Output is correct
20 Correct 58 ms 29632 KB Output is correct
21 Correct 59 ms 30840 KB Output is correct
22 Correct 61 ms 31864 KB Output is correct
23 Correct 67 ms 31864 KB Output is correct
24 Incorrect 195 ms 14968 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 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 376 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 68 ms 32040 KB Output is correct
18 Correct 62 ms 31992 KB Output is correct
19 Correct 64 ms 32020 KB Output is correct
20 Correct 58 ms 29632 KB Output is correct
21 Correct 59 ms 30840 KB Output is correct
22 Correct 61 ms 31864 KB Output is correct
23 Correct 67 ms 31864 KB Output is correct
24 Incorrect 195 ms 14968 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 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 376 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 68 ms 32040 KB Output is correct
18 Correct 62 ms 31992 KB Output is correct
19 Correct 64 ms 32020 KB Output is correct
20 Correct 58 ms 29632 KB Output is correct
21 Correct 59 ms 30840 KB Output is correct
22 Correct 61 ms 31864 KB Output is correct
23 Correct 67 ms 31864 KB Output is correct
24 Incorrect 195 ms 14968 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 207 ms 16220 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 207 ms 16220 KB Output isn't correct
2 Halted 0 ms 0 KB -