Submission #114488

# Submission time Handle Problem Language Result Execution time Memory
114488 2019-06-01T13:06:01 Z Dung Two Dishes (JOI19_dishes) C++11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <iostream>
using namespace std;

unsigned int N,M;

vector<unsigned long> A;
vector<unsigned long> B;
vector<unsigned long long> S;
vector<unsigned long long> T;
vector<long> P;
vector<long> Q;
vector<unsigned long> suma, sumb;
unsigned long sum = 0;
long ans = 0;
unsigned long long curtime = 0;






long dp(const unsigned int & posa,const unsigned int & posb,const short int & state){
  if(state == 1){
  	if(posa < N){
  	  if(posb >= 0){
  	    curtime = suma[posa] + sumb[posb];
  	  }
  	  else{
  	    curtime = suma[posa];
  	  }
  	  if(curtime < S[posa]){
  	    ans += P[posa]; 
  	  }
      tema = posa + 1;
      temb = posb + 1;
      return max(dp(tema, posb,1),dp(posa,temb,-1));
  	  
  	}
  	else{
  	  long long ans1= ans;
      ans -= P[posa - 1];
  	  return ans1;
  	}
  }
  else if(state == -1){
    if(posb < M){
  	  if(posa >= 0){
  	    curtime = suma[posa] + sumb[posb];
  	  }
  	  else{
  	    curtime = sumb[posb];
  	  }
  	  if(curtime < S[posb]){
  	    ans += Q[posb]; 
  	  }
  	  tema = posa + 1;
      temb = posb + 1;
      return max(dp(tema, posb,1),dp(posa,temb,-1));
  	}
  	else{
      long long ans1= ans;
      ans -= Q[posb - 1];
  	  return ans1;
  	}
  }
}

int main(){
  cin >> N >> M;
  A.resize(N);
  S.resize(N);
  P.resize(N);
  suma.resize(N);
  B.resize(M); T.resize(M); Q.resize(M); sumb.resize(M);
  for(int i = 0;i< N;i++){
    cin >> A[i] >> S[i] >> P[i];
    sum += A[i];
    suma[i] = sum;
  }
  sum = 0;
  for(int i = 0;i< M;i++){
    cin >> B[i] >> T[i] >> Q[i];
    sum += B[i];
    sumb[i] = sum;
  }
  cout << max(dp(0,-1,1),dp(-1,0,-1));
  
}

Compilation message

dishes.cpp: In function 'long int dp(const unsigned int&, const unsigned int&, const short int&)':
dishes.cpp:35:7: error: 'tema' was not declared in this scope
       tema = posa + 1;
       ^~~~
dishes.cpp:35:7: note: suggested alternative: 'suma'
       tema = posa + 1;
       ^~~~
       suma
dishes.cpp:36:7: error: 'temb' was not declared in this scope
       temb = posb + 1;
       ^~~~
dishes.cpp:36:7: note: suggested alternative: 'sumb'
       temb = posb + 1;
       ^~~~
       sumb
dishes.cpp:57:6: error: 'tema' was not declared in this scope
      tema = posa + 1;
      ^~~~
dishes.cpp:57:6: note: suggested alternative: 'suma'
      tema = posa + 1;
      ^~~~
      suma
dishes.cpp:58:7: error: 'temb' was not declared in this scope
       temb = posb + 1;
       ^~~~
dishes.cpp:58:7: note: suggested alternative: 'sumb'
       temb = posb + 1;
       ^~~~
       sumb
dishes.cpp: In function 'int main()':
dishes.cpp:76:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0;i< N;i++){
                 ~^~~
dishes.cpp:82:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0;i< M;i++){
                 ~^~~