Submission #1163624

#TimeUsernameProblemLanguageResultExecution timeMemory
1163624salmonAkcija (COCI21_akcija)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int N; int K; vector<long long int> memo[2100]; vector<int> v; const long long int inf = 1.1e18; vector<int> W[2100]; int num = 0; int main(){ scanf(" %d",&N); scanf(" %d",&K); for(int i = 0; i < N; i++){ int w; int d; scanf(" %d",&w); scanf(" %d",&d); W[d].push_back(w); } for(int j = 0; j <= N; j++){ memo[j].push_back(inf); } memo[0][0] = 0; for(int i = 0; i <= N; i++){ for(int l : W[i]){ for(int j = i; j >= max(i-W[i].size() - 5,1); j--){ vector<long long int> v = memo[j - 1]; vector<long long int> v1 = memo[j]; for(int i = 0; i < v.size(); i++){ v[i] += l; } memo[j].clear(); merge(v.begin(),v.end(),v1.begin(),v1.end(),back_inserter(memo[j])); while(memo[j].size() > K) memo[j].pop_back(); } } } int cont = 0; for(int i = N; i >= 0; i--){ for(int j = 0; j < memo[i].size(); j++){ if(memo[i][j] >= inf) continue; printf("%d %lld\n",i,memo[i][j]); cont++; if(cont == K) break; } if(cont == K) break; } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:34:48: error: no matching function for call to 'max(std::vector<int>::size_type, int)'
   34 |                         for(int j = i; j >= max(i-W[i].size() - 5,1); j--){
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~
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:34:48: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
   34 |                         for(int j = i; j >= max(i-W[i].size() - 5,1); j--){
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~
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:34:48: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
   34 |                         for(int j = i; j >= max(i-W[i].size() - 5,1); j--){
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~
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:34:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   34 |                         for(int j = i; j >= max(i-W[i].size() - 5,1); j--){
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~
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:34:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   34 |                         for(int j = i; j >= max(i-W[i].size() - 5,1); j--){
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~
Main.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf(" %d",&N);
      |         ~~~~~^~~~~~~~~~
Main.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf(" %d",&K);
      |         ~~~~~^~~~~~~~~~
Main.cpp:20:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |                 scanf(" %d",&w);
      |                 ~~~~~^~~~~~~~~~
Main.cpp:21:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |                 scanf(" %d",&d);
      |                 ~~~~~^~~~~~~~~~