Submission #924493

#TimeUsernameProblemLanguageResultExecution timeMemory
924493mochaJust Long Neckties (JOI20_ho_t1)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int mx = 2e5+1; int n; pair<int,int> a[mx]; int b[mx]; int d[mx], rd[mx]; int ans[mx]; int main() { cin.tie(0);ios::sync_with_stdio(0); cin >> n; for (int i=0;i<=n;i++) { cin >> a[i].first; a[i].second = i; } for (int i=0;i<n;i++) { cin >> b[i]; } sort(a,a+n+1); sort(b,b+n); d[0] = max(a[0].first-b[0],0); for (int i=1;i<n;i++) { d[i] = max(d[i-1],a[i].first-b[i]); } rd[n-1] = a[n].first - b[n-1]; rd[n-1] = max(d[n-1],0); for (int i=n-2;i>=0;i--) { rd[i] = max(rd[i+1],a[i+1].first-b[i]); } ans[a[0].second] = rd[0]; ans[a[n].second] = d[n-1]; for (int i=0;i<n;i++) { cout << d[i] << " " << rd[i] << "\n"; } for (int i=1;i<n;i++) { ans[a[i].second] = max(d[i-1],rd[i]); } for (int i=0;i<=n;i++) { cout << ans[i] << " "; } cout << "\n"; }

Compilation message (stderr)

cc1plus: error: '::main' must return 'int'
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:24:33: error: no matching function for call to 'max(long long int, int)'
   24 |     d[0] = max(a[0].first-b[0],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 ho_t1.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:
ho_t1.cpp:24:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   24 |     d[0] = max(a[0].first-b[0],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 ho_t1.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:
ho_t1.cpp:24:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   24 |     d[0] = max(a[0].first-b[0],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 ho_t1.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:
ho_t1.cpp:24:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 |     d[0] = max(a[0].first-b[0],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 ho_t1.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:
ho_t1.cpp:24:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 |     d[0] = max(a[0].first-b[0],0);
      |                                 ^
ho_t1.cpp:29:27: error: no matching function for call to 'max(long long int&, int)'
   29 |     rd[n-1] = max(d[n-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 ho_t1.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:
ho_t1.cpp:29:27: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   29 |     rd[n-1] = max(d[n-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 ho_t1.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:
ho_t1.cpp:29:27: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   29 |     rd[n-1] = max(d[n-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 ho_t1.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:
ho_t1.cpp:29:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   29 |     rd[n-1] = max(d[n-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 ho_t1.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:
ho_t1.cpp:29:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   29 |     rd[n-1] = max(d[n-1],0);
      |                           ^