# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
906670 | imarn | Growing Vegetables is Fun 4 (JOI21_ho_t1) | C++14 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);
int n;cin>>n;
ll a[n+1];
for(int i=1;i<=n;i++)cin>>a[i];
ll dpl[n+1];dpl[1]=0;
for(int i=2;i<=n;i++)dpl[i]=dpl[i-1]+(a[i-1]-a[i]>=0?a[i-1]-a[i]+1:0);
ll dpr[n+2]={0};dpr[n]=0;
for(int i=n-1;i>=1;i--)dpr[i]=dpr[i+1]+(a[i+1]-a[i]>=0?a[i+1]-a[i]+1:0);
ll ans=2e18;
//for(int i=1;i<=n;i++)ans=min(ans,max(dpl[i],dpr[i]));
ll now[n+1];
for(int i=1;i<=n;i++)now[i]=a[i];
dpr[n]=0;ll cur=n-2,add=0;
queue<pii>q;
for(int i=n-1;i>=1;i--){
while(!q.empty()&&q.front().f>i)add-=q.front().s,q.pop();
now[i]+=add;
dpr[i]=dpr[i+1]+max(now[i+1]-now[i]+1,0);
int tt=max(now[i+1]-now[i]+1,0);
now[i]+=tt;
while(cur>0&&now[cur]<=now[i])q.push({cur--,tt}),add+=tt;
}
for(int i=1;i<=n-1;i++)ans=min(ans,dpl[i]+dpr[i+1]+max(now[i+1]-a[i]-dpl[i]+1,0));
cout<<ans;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()': Main.cpp:27:48: error: no matching function for call to 'max(long long int, int)' 27 | dpr[i]=dpr[i+1]+max(now[i+1]-now[i]+1,0); | ^ In file included from /usr/include/c++/10/bits/char_traits.h:39, from /usr/include/c++/10/ios:40, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from Main.cpp:1: /usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 254 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/10/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: Main.cpp:27:48: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 27 | dpr[i]=dpr[i+1]+max(now[i+1]-now[i]+1,0); | ^ In file included from /usr/include/c++/10/bits/char_traits.h:39, from /usr/include/c++/10/ios:40, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from Main.cpp:1: /usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 300 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/10/bits/stl_algobase.h:300:5: note: template argument deduction/substitution failed: Main.cpp:27:48: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 27 | dpr[i]=dpr[i+1]+max(now[i+1]-now[i]+1,0); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)' 3480 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/10/bits/stl_algo.h:3480:5: note: template argument deduction/substitution failed: Main.cpp:27:48: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 27 | dpr[i]=dpr[i+1]+max(now[i+1]-now[i]+1,0); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)' 3486 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/10/bits/stl_algo.h:3486:5: note: template argument deduction/substitution failed: Main.cpp:27:48: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 27 | dpr[i]=dpr[i+1]+max(now[i+1]-now[i]+1,0); | ^ Main.cpp:28:39: error: no matching function for call to 'max(long long int, int)' 28 | int tt=max(now[i+1]-now[i]+1,0); | ^ In file included from /usr/include/c++/10/bits/char_traits.h:39, from /usr/include/c++/10/ios:40, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from Main.cpp:1: /usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 254 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/10/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: Main.cpp:28:39: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 28 | int tt=max(now[i+1]-now[i]+1,0); | ^ In file included from /usr/include/c++/10/bits/char_traits.h:39, from /usr/include/c++/10/ios:40, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from Main.cpp:1: /usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 300 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/10/bits/stl_algobase.h:300:5: note: template argument deduction/substitution failed: Main.cpp:28:39: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 28 | int tt=max(now[i+1]-now[i]+1,0); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)' 3480 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/10/bits/stl_algo.h:3480:5: note: template argument deduction/substitution failed: Main.cpp:28:39: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 28 | int tt=max(now[i+1]-now[i]+1,0); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)' 3486 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/10/bits/stl_algo.h:3486:5: note: template argument deduction/substitution failed: Main.cpp:28:39: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 28 | int tt=max(now[i+1]-now[i]+1,0); | ^ Main.cpp:32:84: error: no matching function for call to 'max(long long int, int)' 32 | for(int i=1;i<=n-1;i++)ans=min(ans,dpl[i]+dpr[i+1]+max(now[i+1]-a[i]-dpl[i]+1,0)); | ^ In file included from /usr/include/c++/10/bits/char_traits.h:39, from /usr/include/c++/10/ios:40, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from Main.cpp:1: /usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 254 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/10/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: Main.cpp:32:84: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 32 | for(int i=1;i<=n-1;i++)ans=min(ans,dpl[i]+dpr[i+1]+max(now[i+1]-a[i]-dpl[i]+1,0)); | ^ In file included from /usr/include/c++/10/bits/char_traits.h:39, from /usr/include/c++/10/ios:40, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from Main.cpp:1: /usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 300 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/10/bits/stl_algobase.h:300:5: note: template argument deduction/substitution failed: Main.cpp:32:84: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 32 | for(int i=1;i<=n-1;i++)ans=min(ans,dpl[i]+dpr[i+1]+max(now[i+1]-a[i]-dpl[i]+1,0)); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)' 3480 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/10/bits/stl_algo.h:3480:5: note: template argument deduction/substitution failed: Main.cpp:32:84: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 32 | for(int i=1;i<=n-1;i++)ans=min(ans,dpl[i]+dpr[i+1]+max(now[i+1]-a[i]-dpl[i]+1,0)); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from Main.cpp:1: /usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)' 3486 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/10/bits/stl_algo.h:3486:5: note: template argument deduction/substitution failed: Main.cpp:32:84: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 32 | for(int i=1;i<=n-1;i++)ans=min(ans,dpl[i]+dpr[i+1]+max(now[i+1]-a[i]-dpl[i]+1,0)); | ^