Submission #568679

#TimeUsernameProblemLanguageResultExecution timeMemory
568679dantoh000Growing Vegetables is Fun 4 (JOI21_ho_t1)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int n; int a[200005]; int diff[200005]; int c[200005]; int d[200005]; int pc[200005]; int pd[200005]; int main(){ scanf("%lld",&n); for (int i = 0; i < n; i++){ scanf("%lld",&a[i]); if (i) diff[i] = a[i]-a[i-1]; } for (int i = 1; i < n; i++){ c[i] = max(0,1-diff[i]); d[i] = max(0,diff[i]+1); ///printf("%d: to 1 = %d, to -1 = %d\n",diff[i],c[i],d[i]); pc[i] = pc[i-1] + c[i]; } for (int i = n-1; i >= 1; i--){ pd[i] = pd[i+1] + d[i]; } int ans = -1; for (int i = 1; i <= n; i++){ int NC = max(pc[i-1],pd[i]); if (ans == -1 || ans > NC) ans = NC; } printf("%lld\n",ans); }

Compilation message (stderr)

cc1plus: error: '::main' must return 'int'
Main.cpp: In function 'int main()':
Main.cpp:18:31: error: no matching function for call to 'max(int, long long int)'
   18 |         c[i] = max(0,1-diff[i]);
      |                               ^
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:18:31: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   18 |         c[i] = max(0,1-diff[i]);
      |                               ^
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:18:31: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   18 |         c[i] = max(0,1-diff[i]);
      |                               ^
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:18:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   18 |         c[i] = max(0,1-diff[i]);
      |                               ^
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:18:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   18 |         c[i] = max(0,1-diff[i]);
      |                               ^
Main.cpp:19:31: error: no matching function for call to 'max(int, long long int)'
   19 |         d[i] = max(0,diff[i]+1);
      |                               ^
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:19:31: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   19 |         d[i] = max(0,diff[i]+1);
      |                               ^
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:19:31: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   19 |         d[i] = max(0,diff[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 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:19:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   19 |         d[i] = max(0,diff[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 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:19:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   19 |         d[i] = max(0,diff[i]+1);
      |                               ^
Main.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%lld",&n);
      |     ~~~~~^~~~~~~~~~~
Main.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%lld",&a[i]);
      |         ~~~~~^~~~~~~~~~~~~~