답안 #114478

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
114478 2019-06-01T12:57:02 Z Dung Two Dishes (JOI19_dishes) C++11
컴파일 오류
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(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(){
  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(unsigned int&, unsigned int&, short int&)':
dishes.cpp:35:26: error: cannot bind non-const lvalue reference of type 'unsigned int&' to an rvalue of type 'unsigned int'
       return max(dp(posa + 1, posb,1),dp(posa,posb + 1,-1));
                     ~~~~~^~~
dishes.cpp:23: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:35:52: error: cannot bind non-const lvalue reference of type 'unsigned int&' to an rvalue of type 'unsigned int'
       return max(dp(posa + 1, posb,1),dp(posa,posb + 1,-1));
                                               ~~~~~^~~
dishes.cpp:23: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: In function 'int main()':
dishes.cpp:72:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0;i< N;i++){
                 ~^~~
dishes.cpp:73:9: error: no match for 'operator<<' (operand types are 'std::istream {aka std::basic_istream<char>}' and '__gnu_cxx::__alloc_traits<std::allocator<long unsigned int> >::value_type {aka long unsigned int}')
     cin << A[i] << S[i] << P[i];
dishes.cpp:73:9: note: candidate: operator<<(int, __gnu_cxx::__alloc_traits<std::allocator<long unsigned int> >::value_type {aka long unsigned int}) <built-in>
dishes.cpp:73:9: note:   no known conversion for argument 1 from 'std::istream {aka std::basic_istream<char>}' to 'int'
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/regex.h:1483:5: note: candidate: template<class _Ch_type, class _Ch_traits, class _Bi_iter> std::basic_ostream<_CharT, _Traits>& std::__cxx11::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::__cxx11::sub_match<_Bi_iter>&)
     operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:1483:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:3160:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::piecewise_linear_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:3160:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:2944:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::piecewise_constant_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2944:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:2734:5: note: candidate: template<class _IntType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::discrete_distribution<_IntType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2734:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:2275:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::student_t_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2275:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:2200:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::fisher_f_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2200:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:2036:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::chi_squared_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2036:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:1963:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::lognormal_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:1963:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:1667:5: note: candidate: template<class _IntType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::binomial_distribution<_IntType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:1667:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:1400:5: note: candidate: template<class _IntType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::poisson_distribution<_IntType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:1400:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:1195:5: note: candidate: template<class _IntType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::negative_binomial_distribution<_IntType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:1195:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:831:5: note: candidate: template<class _RandomNumberEngine, long unsigned int __k, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::shuffle_order_engine<_RandomNumberEngine, __k>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:831:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:702:5: note: candidate: template<class _RandomNumberEngine, long unsigned int __p, long unsigned int __r, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::discard_block_engine<_RandomNumberEngine, __p, __r>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:702:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:632:5: note: candidate: template<class _UIntType, long unsigned int __w, long unsigned int __s, long unsigned int __r, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::subtract_with_carry_engine<_UIntType, __w, __s, __r>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:632:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:156:5: note: candidate: template<class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::linear_congruential_engine<_UIntType, __a, __c, __m>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:156:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:2598:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::extreme_value_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2598:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:2522:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::weibull_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2522:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:1731:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::exponential_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:1731:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:2444:5: note: candidate: template<class _RealType1, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::gamma_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2444:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:1080:5: note: candidate: template<class _IntType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::geometric_distribution<_IntType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:1080:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:1898:5: note: candidate: template<class _RealType1, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::normal_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:1898:5: note:   template argument deduction/substitution failed:
dishes.cpp:73:15: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
     cin << A[i] << S[i] << P[i];
               ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from dishes.cpp:1:
/usr/include/c++/7/bits/random.tcc:998:5: note: candidate: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_