Submission #578591

#TimeUsernameProblemLanguageResultExecution timeMemory
578591MrDebooDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n=w.size(); vector<pair<int,int>>v; for(int i=0;i<n;i++)v.push_back({w[i],i}); sort(v.begin(),v.end()); sort(w.begin(),w.end()); long long pre[n]; pre[0]=w[0]; for(int i=1;i<n;i++)pre[i]=pre[i-1]+w[i]; w.push_back(0); long long sm=0,f=n-1; vector<int>vct; for(int i=n;i>=0&&sm<=u;i--){ sm+=w[i]; f=min(f,i-1); while(f>0&&pre[f]+sm>u)f--; if(pre[f]+sm>=l&&pre[f]+sm<=u){ for(int w=0;w<=f;w++)vct.push_back(v[w].second); for(int w=n-1;w>=i;w--)vct.push_back(v[w].second); break; } } return vct; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:18:20: error: no matching function for call to 'min(long long int&, int)'
   18 |         f=min(f,i-1);
      |                    ^
In file included from /usr/include/c++/10/vector:60,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
molecules.cpp:18:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |         f=min(f,i-1);
      |                    ^
In file included from /usr/include/c++/10/vector:60,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
molecules.cpp:18:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |         f=min(f,i-1);
      |                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from molecules.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
molecules.cpp:18:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |         f=min(f,i-1);
      |                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from molecules.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
molecules.cpp:18:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |         f=min(f,i-1);
      |                    ^