# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
114477 | Dung | Two Dishes (JOI19_dishes) | C++11 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
dishes.cpp: In function 'long int dp(unsigned int*, unsigned int*, short int*)': dishes.cpp:24:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] if(state == 1){ ^ dishes.cpp:25:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] if(posa < N){ ^ dishes.cpp:27:27: error: invalid conversion from 'unsigned int*' to 'std::vector<long unsigned int>::size_type {aka long unsigned int}' [-fpermissive] curtime = suma[posa] + sumb[posb]; ^ In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from dishes.cpp:1: /usr/include/c++/7/bits/stl_vector.h:795:7: note: initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = long unsigned int; _Alloc = std::allocator<long unsigned int>; std::vector<_Tp, _Alloc>::reference = long unsigned int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' operator[](size_type __n) _GLIBCXX_NOEXCEPT ^~~~~~~~ dishes.cpp:27:40: error: invalid conversion from 'unsigned int*' to 'std::vector<long unsigned int>::size_type {aka long unsigned int}' [-fpermissive] curtime = suma[posa] + sumb[posb]; ^ In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from dishes.cpp:1: /usr/include/c++/7/bits/stl_vector.h:795:7: note: initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = long unsigned int; _Alloc = std::allocator<long unsigned int>; std::vector<_Tp, _Alloc>::reference = long unsigned int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' operator[](size_type __n) _GLIBCXX_NOEXCEPT ^~~~~~~~ dishes.cpp:30:27: error: invalid conversion from 'unsigned int*' to 'std::vector<long unsigned int>::size_type {aka long unsigned int}' [-fpermissive] curtime = suma[posa]; ^ In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from dishes.cpp:1: /usr/include/c++/7/bits/stl_vector.h:795:7: note: initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = long unsigned int; _Alloc = std::allocator<long unsigned int>; std::vector<_Tp, _Alloc>::reference = long unsigned int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' operator[](size_type __n) _GLIBCXX_NOEXCEPT ^~~~~~~~ dishes.cpp:32:25: error: invalid conversion from 'unsigned int*' to 'std::vector<long long unsigned int>::size_type {aka long unsigned int}' [-fpermissive] if(curtime < S[posa]){ ^ In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from dishes.cpp:1: /usr/include/c++/7/bits/stl_vector.h:795:7: note: initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = long long unsigned int; _Alloc = std::allocator<long long unsigned int>; std::vector<_Tp, _Alloc>::reference = long long unsigned int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' operator[](size_type __n) _GLIBCXX_NOEXCEPT ^~~~~~~~ dishes.cpp:33:21: error: invalid conversion from 'unsigned int*' to 'std::vector<long int>::size_type {aka long unsigned int}' [-fpermissive] ans += P[posa]; ^ In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from dishes.cpp:1: /usr/include/c++/7/bits/stl_vector.h:795:7: note: initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = long int; _Alloc = std::allocator<long int>; std::vector<_Tp, _Alloc>::reference = long int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' operator[](size_type __n) _GLIBCXX_NOEXCEPT ^~~~~~~~ dishes.cpp:35:37: error: invalid conversion from 'int' to 'short int*' [-fpermissive] return max(dp(posa + 1, posb,1),dp(posa,posb + 1,-1)); ^ dishes.cpp:23: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:35:58: error: invalid conversion from 'int' to 'short int*' [-fpermissive] return max(dp(posa + 1, posb,1),dp(posa,posb + 1,-1)); ^ dishes.cpp:23: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:40:21: error: invalid conversion from 'unsigned int*' to 'std::vector<long int>::size_type {aka long unsigned int}' [-fpermissive] ans -= P[posa - 1]; ~~~~~^~~ In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from dishes.cpp:1: /usr/include/c++/7/bits/stl_vector.h:795:7: note: initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = long int; _Alloc = std::allocator<long int>; std::vector<_Tp, _Alloc>::reference = long int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' operator[](size_type __n) _GLIBCXX_NOEXCEPT ^~~~~~~~ dishes.cpp:44:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] else if(state == -1){ ^ dishes.cpp:45:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] if(posb < M){ ^ dishes.cpp:47:27: error: invalid conversion from 'unsigned int*' to 'std::vector<long unsigned int>::size_type {aka long unsigned int}' [-fpermissive] curtime = suma[posa] + sumb[posb]; ^ In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from dishes.cpp:1: /usr/include/c++/7/bits/stl_vector.h:795:7: note: initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = long unsigned int; _Alloc = std::allocator<long unsigned int>; std::vector<_Tp, _Alloc>::reference = long unsigned int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' operator[](size_type __n) _GLIBCXX_NOEXCEPT ^~~~~~~~ dishes.cpp:47:40: error: invalid conversion from 'unsigned int*' to 'std::vector<long unsigned int>::size_type {aka long unsigned int}' [-fpermissive] curtime = suma[posa] + sumb[posb]; ^ In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from dishes.cpp:1: /usr/include/c++/7/bits/stl_vector.h:795:7: note: initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = long unsigned int; _Alloc = std::allocator<long unsigned int>; std::vector<_Tp, _Alloc>::reference = long unsigned int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' operator[](size_type __n) _GLIBCXX_NOEXCEPT ^~~~~~~~ dishes.cpp:50:27: error: invalid conversion from 'unsigned int*' to 'std::vector<long unsigned int>::size_type {aka long unsigned int}' [-fpermissive] curtime = sumb[posb]; ^ In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from dishes.cpp:1: /usr/include/c++/7/bits/stl_vector.h:795:7: note: initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = long unsigned int; _Alloc = std::allocator<long unsigned int>; std::vector<_Tp, _Alloc>::reference = long unsigned int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' operator[](size_type __n) _GLIBCXX_NOEXCEPT ^~~~~~~~ dishes.cpp:52:25: error: invalid conversion from 'unsigned int*' to 'std::vector<long long unsigned int>::size_type {aka long unsigned int}' [-fpermissive] if(curtime < S[posb]){ ^ In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from dishes.cpp:1: /usr/include/c++/7/bits/stl_vector.h:795:7: note: initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = long long unsigned int; _Alloc = std::allocator<long long unsigned int>; std::vector<_Tp, _Alloc>::reference = long long unsigned int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' operator[](size_type __n) _GLIBCXX_NOEXCEPT ^~~~~~~~ dishes.cpp:53:21: error: invalid conversion from 'unsigned int*' to 'std::vector<long int>::size_type {aka long unsigned int}' [-fpermissive] ans += Q[posb]; ^ In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from dishes.cpp:1: /usr/include/c++/7/bits/stl_vector.h:795:7: note: initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = long int; _Alloc = std::allocator<long int>; std::vector<_Tp, _Alloc>::reference = long int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' operator[](size_type __n) _GLIBCXX_NOEXCEPT ^~~~~~~~ dishes.cpp:59:21: error: invalid conversion from 'unsigned int*' to 'std::vector<long int>::size_type {aka long unsigned int}' [-fpermissive] ans -= Q[posb - 1]; ~~~~~^~~ In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from dishes.cpp:1: /usr/include/c++/7/bits/stl_vector.h:795:7: note: initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = long int; _Alloc = std::allocator<long int>; std::vector<_Tp, _Alloc>::reference = long int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' operator[](size_type __n) _GLIBCXX_NOEXCEPT ^~~~~~~~ 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/ra