Submission #114501

# Submission time Handle Problem Language Result Execution time Memory
114501 2019-06-01T13:24:57 Z Dung Two Dishes (JOI19_dishes) C++11
0 / 100
567 ms 25444 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]; 
  	  }
      unsigned int tema = posa + 1;
      unsigned int 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]; 
  	  }
  	  unsigned int tema = posa + 1;
      unsigned int 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 '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++){
                 ~^~~
dishes.cpp: In function 'long int dp(const unsigned int&, const unsigned int&, const short int&)':
dishes.cpp:67:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Runtime error 567 ms 25444 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 2 ms 384 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 2 ms 384 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 2 ms 384 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 2 ms 384 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 2 ms 384 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 567 ms 25444 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 567 ms 25444 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -