Submission #1247781

#TimeUsernameProblemLanguageResultExecution timeMemory
1247781chaeryeongSki 2 (JOI24_ski2)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; //#define int long long int dp[81][81][81][81]; vector <int> heights[81]; int n, k, h[41],c[41]; vector <int> dist; int ans (int w,int x,int y, int z){ if(w==81){ if(x==0)return 0; return 1e18; } int &ret=dp[w][x][y][z]; if(ret !=-1)return ret; ret=1e18; auto g = heights[w]; for(int i=1;i<=x;i++)g.push_back(dist.size()-1); ret = min(ret, ans(w+1,g.size(),y,z)+k*(int)g.size()); if(y==0){ ret=min(ret,ans(w+1,g.size()-1,1,g[0])+k*((int)g.size()-1)); return ret; } for(int i=0;i<g.size();i++){ ret=min(ret,ans(w+1,g.size()-i-1,max(0ll,y-(i+1))+i+1,min(g[0],z))+dist[z]*max(0ll,i+1-y)+k*((int)g.size()-1-i)); } return ret; } signed main (){ cin>>n>>k; for(int i=1;i<=n;i++){ cin>>h[i]>>c[i]; dist.push_back(c[i]); } dist.push_back(1e18); sort(dist.begin(),dist.end()); dist.resize(unique(dist.begin(),dist.end())-dist.begin()); for(int i=1;i<=n;i++){ int x=lower_bound(dist.begin(),dist.end(),c[i])-dist.begin(); heights[h[i]].push_back(x); } for (int i=0;i<=40;i++){ sort(heights[i].begin(),heights[i].end()); } memset(dp,-1,sizeof(dp)); cout<<ans(0,0,0,dist.size()-1)<<endl; }

Compilation message (stderr)

Main.cpp: In function 'int ans(int, int, int, int)':
Main.cpp:11:8: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   11 | return 1e18;
      |        ^~~~
Main.cpp:15:5: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   15 | ret=1e18;
      |     ^~~~
Main.cpp:24:37: error: no matching function for call to 'max(long long int, int)'
   24 | ret=min(ret,ans(w+1,g.size()-i-1,max(0ll,y-(i+1))+i+1,min(g[0],z))+dist[z]*max(0ll,i+1-y)+k*((int)g.size()-1-i));
      |                                  ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
Main.cpp:24:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   24 | ret=min(ret,ans(w+1,g.size()-i-1,max(0ll,y-(i+1))+i+1,min(g[0],z))+dist[z]*max(0ll,i+1-y)+k*((int)g.size()-1-i));
      |                                  ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
Main.cpp:24:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   24 | ret=min(ret,ans(w+1,g.size()-i-1,max(0ll,y-(i+1))+i+1,min(g[0],z))+dist[z]*max(0ll,i+1-y)+k*((int)g.size()-1-i));
      |                                  ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
Main.cpp:24:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 | ret=min(ret,ans(w+1,g.size()-i-1,max(0ll,y-(i+1))+i+1,min(g[0],z))+dist[z]*max(0ll,i+1-y)+k*((int)g.size()-1-i));
      |                                  ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
Main.cpp:24:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 | ret=min(ret,ans(w+1,g.size()-i-1,max(0ll,y-(i+1))+i+1,min(g[0],z))+dist[z]*max(0ll,i+1-y)+k*((int)g.size()-1-i));
      |                                  ~~~^~~~~~~~~~~~~
Main.cpp:24:79: error: no matching function for call to 'max(long long int, int)'
   24 | ret=min(ret,ans(w+1,g.size()-i-1,max(0ll,y-(i+1))+i+1,min(g[0],z))+dist[z]*max(0ll,i+1-y)+k*((int)g.size()-1-i));
      |                                                                            ~~~^~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
Main.cpp:24:79: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   24 | ret=min(ret,ans(w+1,g.size()-i-1,max(0ll,y-(i+1))+i+1,min(g[0],z))+dist[z]*max(0ll,i+1-y)+k*((int)g.size()-1-i));
      |                                                                            ~~~^~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
Main.cpp:24:79: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   24 | ret=min(ret,ans(w+1,g.size()-i-1,max(0ll,y-(i+1))+i+1,min(g[0],z))+dist[z]*max(0ll,i+1-y)+k*((int)g.size()-1-i));
      |                                                                            ~~~^~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
Main.cpp:24:79: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 | ret=min(ret,ans(w+1,g.size()-i-1,max(0ll,y-(i+1))+i+1,min(g[0],z))+dist[z]*max(0ll,i+1-y)+k*((int)g.size()-1-i));
      |                                                                            ~~~^~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
Main.cpp:24:79: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 | ret=min(ret,ans(w+1,g.size()-i-1,max(0ll,y-(i+1))+i+1,min(g[0],z))+dist[z]*max(0ll,i+1-y)+k*((int)g.size()-1-i));
      |                                                                            ~~~^~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:34:16: warning: overflow in conversion from 'double' to 'std::vector<int>::value_type' {aka 'int'} changes value from '1.0e+18' to '2147483647' [-Woverflow]
   34 | dist.push_back(1e18);
      |                ^~~~