Submission #563946

# Submission time Handle Problem Language Result Execution time Memory
563946 2022-05-18T09:56:26 Z dantoh000 Two Dishes (JOI19_dishes) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000000000;
int n,m;
int a[200005], s[200005], p[200005];
int b[200005], t[200005], q[200005];
int pa[200005];
int pb[200005];
int mem[2005][2005];
int dp(int i, int j){
    if (i == n+1 && j == m+1) return 0;
    if (mem[i][j] != -1) return mem[i][j];
    int T = pa[i-1] + pb[j-1];
    int ret = -INF;
    if (i != n+1){
        ret = max(ret, dp(i+1, j) + ((T+a[i] <= s[i])?p[i]:0));
    }
    if (j != m+1){
        ret = max(ret, dp(i, j+1) + ((T+b[j] <= t[j])?q[j]:0));
    }
    //printf("%d %d %d %d\n",i,j,T,ret);
    return mem[i][j] = ret;
}
main(){
    scanf("%lld%lld",&n,&m);
    for (int i = 1; i <= n; i++){
        scanf("%lld%lld%lld",&a[i],&s[i],&p[i]);
        pa[i] = pa[i-1] + a[i];
        pp[i] = pp[i-1] + p[i];
    }
    for (int i = 1; i <= m; i++){
        scanf("%lld%lld%lld",&b[i],&t[i],&q[i]);
        pb[i] = pb[i-1] + b[i];
        pq[i] = pq[i-1] + q[i];
    }
    if (n <= 2000 && m <= 2000){
        memset(mem,-1,sizeof(mem));
        printf("%lld",dp(1,1));
    }
    else{
        if (s[1] > t[1]){
            swap(n,m);
            swap(a,b);
            swap(s,t);
            swap(p,q);
        }
        return 0;
    }
}

Compilation message

dishes.cpp:25:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   25 | main(){
      | ^~~~
dishes.cpp: In function 'int main()':
dishes.cpp:30:9: error: 'pp' was not declared in this scope; did you mean 'dp'?
   30 |         pp[i] = pp[i-1] + p[i];
      |         ^~
      |         dp
dishes.cpp:35:9: error: 'pq' was not declared in this scope; did you mean 'pb'?
   35 |         pq[i] = pq[i-1] + q[i];
      |         ^~
      |         pb
dishes.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     scanf("%lld%lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
dishes.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf("%lld%lld%lld",&a[i],&s[i],&p[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         scanf("%lld%lld%lld",&b[i],&t[i],&q[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~