Submission #122806

# Submission time Handle Problem Language Result Execution time Memory
122806 2019-06-29T09:59:35 Z sealnot123 Two Dishes (JOI19_dishes) C++14
10 / 100
1802 ms 78088 KB
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef double D;
typedef long double LD;
const int N = 2020;
LL dp[N][N];
LL A[N], B[N], S[N], T[N], P[N], Q[N];
int main(){
    int n, m;
    int i,j,k,l;
    int a,b,c,d;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++){
        scanf("%lld%lld%lld",&A[i],&S[i],&P[i]);
        A[i] += A[i-1];
    }
    for(i=1;i<=m;i++){
        scanf("%lld%lld%lld",&B[i],&T[i],&Q[i]);
        B[i] += B[i-1];
    }
    for(i=0;i<=n;i++){
        for(j=0;j<=m;j++){
            if(i+j==0) continue;
            if(i>0) dp[i][j] = max(dp[i-1][j] + P[i]*(A[i]+B[j]<=S[i]), dp[i][j]);
            if(j>0) dp[i][j] = max(dp[i][j], dp[i][j-1] + Q[j]*(A[i]+B[j]<=T[j]));
            // printf("%d %d : %lld\n",i ,j, dp[i][j]);
        }
    }
    printf("%lld",dp[n][m]);
    return 0;
}
/*
4 3
2 1 1
3 8 1
2 13 1
1 13 1
3 6 1
2 11 1
2 15 1

4 3
2 1 1
3 8 1
2 13 1
1 13 1
3 6 1
2 11 1
2 13 1
*/

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:19:13: warning: unused variable 'k' [-Wunused-variable]
     int i,j,k,l;
             ^
dishes.cpp:19:15: warning: unused variable 'l' [-Wunused-variable]
     int i,j,k,l;
               ^
dishes.cpp:20:9: warning: unused variable 'a' [-Wunused-variable]
     int a,b,c,d;
         ^
dishes.cpp:20:11: warning: unused variable 'b' [-Wunused-variable]
     int a,b,c,d;
           ^
dishes.cpp:20:13: warning: unused variable 'c' [-Wunused-variable]
     int a,b,c,d;
             ^
dishes.cpp:20:15: warning: unused variable 'd' [-Wunused-variable]
     int a,b,c,d;
               ^
dishes.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
dishes.cpp:23:14: 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:27:14: 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 Runtime error 1802 ms 78088 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 Correct 2 ms 376 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 380 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 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 380 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 58 ms 32264 KB Output is correct
18 Correct 55 ms 32120 KB Output is correct
19 Correct 55 ms 32280 KB Output is correct
20 Correct 54 ms 32120 KB Output is correct
21 Correct 54 ms 30968 KB Output is correct
22 Correct 55 ms 32120 KB Output is correct
23 Correct 55 ms 32120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 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 380 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 58 ms 32264 KB Output is correct
18 Correct 55 ms 32120 KB Output is correct
19 Correct 55 ms 32280 KB Output is correct
20 Correct 54 ms 32120 KB Output is correct
21 Correct 54 ms 30968 KB Output is correct
22 Correct 55 ms 32120 KB Output is correct
23 Correct 55 ms 32120 KB Output is correct
24 Runtime error 1783 ms 75908 KB Execution killed with signal 11 (could be triggered by violating memory limits)
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 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 380 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 58 ms 32264 KB Output is correct
18 Correct 55 ms 32120 KB Output is correct
19 Correct 55 ms 32280 KB Output is correct
20 Correct 54 ms 32120 KB Output is correct
21 Correct 54 ms 30968 KB Output is correct
22 Correct 55 ms 32120 KB Output is correct
23 Correct 55 ms 32120 KB Output is correct
24 Runtime error 1783 ms 75908 KB Execution killed with signal 11 (could be triggered by violating memory limits)
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 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 380 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 58 ms 32264 KB Output is correct
18 Correct 55 ms 32120 KB Output is correct
19 Correct 55 ms 32280 KB Output is correct
20 Correct 54 ms 32120 KB Output is correct
21 Correct 54 ms 30968 KB Output is correct
22 Correct 55 ms 32120 KB Output is correct
23 Correct 55 ms 32120 KB Output is correct
24 Runtime error 1783 ms 75908 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1802 ms 78088 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 1802 ms 78088 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -