답안 #114474

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
114474 2019-06-01T12:48:35 Z Dung Two Dishes (JOI19_dishes) C++11
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
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:5:1: error: 'cin' does not name a type; did you mean 'sin'?
 cin << N << M;
 ^~~
 sin
dishes.cpp:6:18: error: array bound is not an integer constant before ']' token
 unsigned long A[N];
                  ^
dishes.cpp:7:18: error: array bound is not an integer constant before ']' token
 unsigned long B[M];
                  ^
dishes.cpp:8:23: error: array bound is not an integer constant before ']' token
 unsigned long long S[N];
                       ^
dishes.cpp:9:23: error: array bound is not an integer constant before ']' token
 unsigned long long T[M];
                       ^
dishes.cpp:10:9: error: array bound is not an integer constant before ']' token
 long P[N];
         ^
dishes.cpp:11:9: error: array bound is not an integer constant before ']' token
 long Q[M];
         ^
dishes.cpp:12:21: error: array bound is not an integer constant before ']' token
 unsigned long suma[N], sumb[M];
                     ^
dishes.cpp:12:30: error: array bound is not an integer constant before ']' token
 unsigned long suma[N], sumb[M];
                              ^
dishes.cpp:16:1: error: expected unqualified-id before 'for'
 for(int i = 0;i< N;i++){
 ^~~
dishes.cpp:16:15: error: 'i' does not name a type
 for(int i = 0;i< N;i++){
               ^
dishes.cpp:16:20: error: 'i' does not name a type
 for(int i = 0;i< N;i++){
                    ^
dishes.cpp:21:1: error: 'sum' does not name a type
 sum = 0;
 ^~~
dishes.cpp:22:1: error: expected unqualified-id before 'for'
 for(int i = 0;i< M;i++){
 ^~~
dishes.cpp:22:15: error: 'i' does not name a type
 for(int i = 0;i< M;i++){
               ^
dishes.cpp:22: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:33:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   if(state == 1){
               ^
dishes.cpp:34:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    if(posa < N){
              ^
dishes.cpp:36:18: error: 'suma' was not declared in this scope
        curtime = suma[posa] + sumb[posb];
                  ^~~~
dishes.cpp:36:18: note: suggested alternative: 'sum'
        curtime = suma[posa] + sumb[posb];
                  ^~~~
                  sum
dishes.cpp:36:31: error: 'sumb' was not declared in this scope
        curtime = suma[posa] + sumb[posb];
                               ^~~~
dishes.cpp:36:31: note: suggested alternative: 'sum'
        curtime = suma[posa] + sumb[posb];
                               ^~~~
                               sum
dishes.cpp:39:18: error: 'suma' was not declared in this scope
        curtime = suma[posa];
                  ^~~~
dishes.cpp:39:18: note: suggested alternative: 'sum'
        curtime = suma[posa];
                  ^~~~
                  sum
dishes.cpp:41:19: error: 'S' was not declared in this scope
      if(curtime < S[posa]){
                   ^
dishes.cpp:42:15: error: 'P' was not declared in this scope
        ans += P[posa]; 
               ^
dishes.cpp:44:37: error: invalid conversion from 'int' to 'short int*' [-fpermissive]
       return max(dp(posa + 1, posb,1),dp(posa,posb + 1,-1));
                                     ^
dishes.cpp:32: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:44:58: error: invalid conversion from 'int' to 'short int*' [-fpermissive]
       return max(dp(posa + 1, posb,1),dp(posa,posb + 1,-1));
                                                          ^
dishes.cpp:32: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:49:14: error: 'P' was not declared in this scope
       ans -= P[posa - 1];
              ^
dishes.cpp:53:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   else if(state == -1){
                     ^
dishes.cpp:54:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
     if(posb < M){
               ^
dishes.cpp:56:18: error: 'suma' was not declared in this scope
        curtime = suma[posa] + sumb[posb];
                  ^~~~
dishes.cpp:56:18: note: suggested alternative: 'sum'
        curtime = suma[posa] + sumb[posb];
                  ^~~~
                  sum
dishes.cpp:56:31: error: 'sumb' was not declared in this scope
        curtime = suma[posa] + sumb[posb];
                               ^~~~
dishes.cpp:56:31: note: suggested alternative: 'sum'
        curtime = suma[posa] + sumb[posb];
                               ^~~~
                               sum
dishes.cpp:59:18: error: 'sumb' was not declared in this scope
        curtime = sumb[posb];
                  ^~~~
dishes.cpp:59:18: note: suggested alternative: 'sum'
        curtime = sumb[posb];
                  ^~~~
                  sum
dishes.cpp:61:19: error: 'S' was not declared in this scope
      if(curtime < S[posb]){
                   ^
dishes.cpp:62:15: error: 'Q' was not declared in this scope
        ans += Q[posb]; 
               ^
dishes.cpp:68:14: error: 'Q' was not declared in this scope
       ans -= Q[posb - 1];
              ^
dishes.cpp: In function 'int main()':
dishes.cpp:75:24: error: invalid conversion from 'int' to 'unsigned int*' [-fpermissive]
   cout << max(dp(0,-1,1),dp(-1,0,-1));
                        ^
dishes.cpp:32: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:75:24: error: invalid conversion from 'int' to 'short int*' [-fpermissive]
   cout << max(dp(0,-1,1),dp(-1,0,-1));
                        ^
dishes.cpp:32: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:75:36: error: invalid conversion from 'int' to 'unsigned int*' [-fpermissive]
   cout << max(dp(0,-1,1),dp(-1,0,-1));
                                    ^
dishes.cpp:32: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:75:36: error: invalid conversion from 'int' to 'short int*' [-fpermissive]
   cout << max(dp(0,-1,1),dp(-1,0,-1));
                                    ^
dishes.cpp:32: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:72:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^