Submission #114475

# Submission time Handle Problem Language Result Execution time Memory
114475 2019-06-01T12:49:40 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;
cin << N << M;
unsigned long A[N];
unsigned long B[M];
unsigned long long S[N];
unsigned long long T[M];
long P[N];
long Q[M];
unsigned long suma[N], sumb[M];
unsigned long sum = 0;
long ans = 0;
unsigned long long curtime = 0;
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;
}





long dp(unsigned int* posa,unsigned int* posb,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]; 
  	  }
      return max(dp(posa + 1, posb,1),dp(posa,posb + 1,-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]; 
  	  }
  	  
  	}
  	else{
      long long ans1= ans;
      ans -= Q[posb - 1];
  	  return ans1;
  	}
  }
}

int main(){
  cout << max(dp(0,-1,1),dp(-1,0,-1));
  
}

Compilation message

dishes.cpp:6:1: error: 'cin' does not name a type; did you mean 'sin'?
 cin << N << M;
 ^~~
 sin
dishes.cpp:7:18: error: array bound is not an integer constant before ']' token
 unsigned long A[N];
                  ^
dishes.cpp:8:18: error: array bound is not an integer constant before ']' token
 unsigned long B[M];
                  ^
dishes.cpp:9:23: error: array bound is not an integer constant before ']' token
 unsigned long long S[N];
                       ^
dishes.cpp:10:23: error: array bound is not an integer constant before ']' token
 unsigned long long T[M];
                       ^
dishes.cpp:11:9: error: array bound is not an integer constant before ']' token
 long P[N];
         ^
dishes.cpp:12:9: error: array bound is not an integer constant before ']' token
 long Q[M];
         ^
dishes.cpp:13:21: error: array bound is not an integer constant before ']' token
 unsigned long suma[N], sumb[M];
                     ^
dishes.cpp:13:30: error: array bound is not an integer constant before ']' token
 unsigned long suma[N], sumb[M];
                              ^
dishes.cpp:17:1: error: expected unqualified-id before 'for'
 for(int i = 0;i< N;i++){
 ^~~
dishes.cpp:17:15: error: 'i' does not name a type
 for(int i = 0;i< N;i++){
               ^
dishes.cpp:17:20: error: 'i' does not name a type
 for(int i = 0;i< N;i++){
                    ^
dishes.cpp:22:1: error: 'sum' does not name a type
 sum = 0;
 ^~~
dishes.cpp:23:1: error: expected unqualified-id before 'for'
 for(int i = 0;i< M;i++){
 ^~~
dishes.cpp:23:15: error: 'i' does not name a type
 for(int i = 0;i< M;i++){
               ^
dishes.cpp:23:20: error: 'i' does not name a type
 for(int i = 0;i< M;i++){
                    ^
dishes.cpp: In function 'long int dp(unsigned int*, unsigned int*, short int*)':
dishes.cpp:34:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   if(state == 1){
               ^
dishes.cpp:35:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    if(posa < N){
              ^
dishes.cpp:37:18: error: 'suma' was not declared in this scope
        curtime = suma[posa] + sumb[posb];
                  ^~~~
dishes.cpp:37:18: note: suggested alternative: 'sum'
        curtime = suma[posa] + sumb[posb];
                  ^~~~
                  sum
dishes.cpp:37:31: error: 'sumb' was not declared in this scope
        curtime = suma[posa] + sumb[posb];
                               ^~~~
dishes.cpp:37:31: note: suggested alternative: 'sum'
        curtime = suma[posa] + sumb[posb];
                               ^~~~
                               sum
dishes.cpp:40:18: error: 'suma' was not declared in this scope
        curtime = suma[posa];
                  ^~~~
dishes.cpp:40:18: note: suggested alternative: 'sum'
        curtime = suma[posa];
                  ^~~~
                  sum
dishes.cpp:42:19: error: 'S' was not declared in this scope
      if(curtime < S[posa]){
                   ^
dishes.cpp:43:15: error: 'P' was not declared in this scope
        ans += P[posa]; 
               ^
dishes.cpp:45:37: error: invalid conversion from 'int' to 'short int*' [-fpermissive]
       return max(dp(posa + 1, posb,1),dp(posa,posb + 1,-1));
                                     ^
dishes.cpp:33:6: note:   initializing argument 3 of 'long int dp(unsigned int*, unsigned int*, short int*)'
 long dp(unsigned int* posa,unsigned int* posb,short int * state){
      ^~
dishes.cpp:45:58: error: invalid conversion from 'int' to 'short int*' [-fpermissive]
       return max(dp(posa + 1, posb,1),dp(posa,posb + 1,-1));
                                                          ^
dishes.cpp:33:6: note:   initializing argument 3 of 'long int dp(unsigned int*, unsigned int*, short int*)'
 long dp(unsigned int* posa,unsigned int* posb,short int * state){
      ^~
dishes.cpp:50:14: error: 'P' was not declared in this scope
       ans -= P[posa - 1];
              ^
dishes.cpp:54:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   else if(state == -1){
                     ^
dishes.cpp:55:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
     if(posb < M){
               ^
dishes.cpp:57:18: error: 'suma' was not declared in this scope
        curtime = suma[posa] + sumb[posb];
                  ^~~~
dishes.cpp:57:18: note: suggested alternative: 'sum'
        curtime = suma[posa] + sumb[posb];
                  ^~~~
                  sum
dishes.cpp:57:31: error: 'sumb' was not declared in this scope
        curtime = suma[posa] + sumb[posb];
                               ^~~~
dishes.cpp:57:31: note: suggested alternative: 'sum'
        curtime = suma[posa] + sumb[posb];
                               ^~~~
                               sum
dishes.cpp:60:18: error: 'sumb' was not declared in this scope
        curtime = sumb[posb];
                  ^~~~
dishes.cpp:60:18: note: suggested alternative: 'sum'
        curtime = sumb[posb];
                  ^~~~
                  sum
dishes.cpp:62:19: error: 'S' was not declared in this scope
      if(curtime < S[posb]){
                   ^
dishes.cpp:63:15: error: 'Q' was not declared in this scope
        ans += Q[posb]; 
               ^
dishes.cpp:69:14: error: 'Q' was not declared in this scope
       ans -= Q[posb - 1];
              ^
dishes.cpp: In function 'int main()':
dishes.cpp:76:24: error: invalid conversion from 'int' to 'unsigned int*' [-fpermissive]
   cout << max(dp(0,-1,1),dp(-1,0,-1));
                        ^
dishes.cpp:33:6: note:   initializing argument 2 of 'long int dp(unsigned int*, unsigned int*, short int*)'
 long dp(unsigned int* posa,unsigned int* posb,short int * state){
      ^~
dishes.cpp:76:24: error: invalid conversion from 'int' to 'short int*' [-fpermissive]
   cout << max(dp(0,-1,1),dp(-1,0,-1));
                        ^
dishes.cpp:33:6: note:   initializing argument 3 of 'long int dp(unsigned int*, unsigned int*, short int*)'
 long dp(unsigned int* posa,unsigned int* posb,short int * state){
      ^~
dishes.cpp:76:36: error: invalid conversion from 'int' to 'unsigned int*' [-fpermissive]
   cout << max(dp(0,-1,1),dp(-1,0,-1));
                                    ^
dishes.cpp:33:6: note:   initializing argument 1 of 'long int dp(unsigned int*, unsigned int*, short int*)'
 long dp(unsigned int* posa,unsigned int* posb,short int * state){
      ^~
dishes.cpp:76:36: error: invalid conversion from 'int' to 'short int*' [-fpermissive]
   cout << max(dp(0,-1,1),dp(-1,0,-1));
                                    ^
dishes.cpp:33:6: note:   initializing argument 3 of 'long int dp(unsigned int*, unsigned int*, short int*)'
 long dp(unsigned int* posa,unsigned int* posb,short int * state){
      ^~
dishes.cpp: In function 'long int dp(unsigned int*, unsigned int*, short int*)':
dishes.cpp:73:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^