Submission #203513

# Submission time Handle Problem Language Result Execution time Memory
203513 2020-02-21T05:32:48 Z arman_ferdous Just Long Neckties (JOI20_ho_t1) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5+100;

int n;
struct data{
	int x, idx;
}a[N];
int b[N];

int pre[N], suf[N], ans[N];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n + 1; i++) {
		scanf("%d", &a[i].x);
		a[i].idx = i;
	} for(int i = 1; i <= n; i++) scanf("%d", &b[i]);
	sort(a + 1, a + n + 2, [&](data a, data b) {
		return a.x < b.x;
	});
	sort(b + 1, b + n + 1);

	for(int i = 1; i <= n; i++) 
		pre[i] = max(a[i].x - b[i], 0);
	for(int i = n; i > 0; i--)
		suf[i] = max(a[i + 1].x - b[i], 0);
	for(int i = 2; i <= n; i++) pre[i] = max(pre[i], pre[i - 1]);
	for(int i = n - 1; i > 0; i--) suf[i] = max(suf[i], suf[i + 1]);

	for(int i = 1; i <= n + 1; i++) {
		ans[a[i].idx] = max(pre[i - 1], suf[i]);
	} for(int i = 1; i <= n + 1; i++)
		printf("%d ", ans[i]);
	return 0;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:20:29: error: reference to 'data' is ambiguous
  sort(a + 1, a + n + 2, [&](data a, data b) {
                             ^~~~
ho_t1.cpp:7:8: note: candidates are: struct data
 struct data{
        ^~~~
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from ho_t1.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
ho_t1.cpp:20:29: error: 'data' has not been declared
  sort(a + 1, a + n + 2, [&](data a, data b) {
                             ^~~~
ho_t1.cpp:20:37: error: reference to 'data' is ambiguous
  sort(a + 1, a + n + 2, [&](data a, data b) {
                                     ^~~~
ho_t1.cpp:7:8: note: candidates are: struct data
 struct data{
        ^~~~
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from ho_t1.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
ho_t1.cpp:20:37: error: 'data' has not been declared
  sort(a + 1, a + n + 2, [&](data a, data b) {
                                     ^~~~
ho_t1.cpp: In lambda function:
ho_t1.cpp:21:12: error: request for member 'x' in 'a', which is of non-class type 'int'
   return a.x < b.x;
            ^
ho_t1.cpp:21:18: error: request for member 'x' in 'b', which is of non-class type 'int'
   return a.x < b.x;
                  ^
In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/7/bits/specfun.h:45,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from ho_t1.cpp:1:
/usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = data*; _Iterator2 = data*; _Compare = main()::<lambda(int, int)>]':
/usr/include/c++/7/bits/stl_algo.h:81:17:   required from 'void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int, int)> >]'
/usr/include/c++/7/bits/stl_algo.h:1921:34:   required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int, int)> >]'
/usr/include/c++/7/bits/stl_algo.h:1953:38:   required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = data*; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int, int)> >]'
/usr/include/c++/7/bits/stl_algo.h:1968:25:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int, int)> >]'
/usr/include/c++/7/bits/stl_algo.h:4868:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = main()::<lambda(int, int)>]'
ho_t1.cpp:22:3:   required from here
/usr/include/c++/7/bits/predefined_ops.h:143:18: error: no match for call to '(main()::<lambda(int, int)>) (data&, data&)'
         { return bool(_M_comp(*__it1, *__it2)); }
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:20:43: note: candidate: main()::<lambda(int, int)>
  sort(a + 1, a + n + 2, [&](data a, data b) {
                                           ^
ho_t1.cpp:20:43: note:   no known conversion for argument 1 from 'data' to 'int'
In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/7/bits/specfun.h:45,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from ho_t1.cpp:1:
/usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = data; _Iterator = data*; _Compare = main()::<lambda(int, int)>]':
/usr/include/c++/7/bits/stl_algo.h:1828:20:   required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Val_comp_iter<main()::<lambda(int, int)> >]'
/usr/include/c++/7/bits/stl_algo.h:1855:36:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int, int)> >]'
/usr/include/c++/7/bits/stl_algo.h:1885:25:   required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int, int)> >]'
/usr/include/c++/7/bits/stl_algo.h:1971:31:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int, int)> >]'
/usr/include/c++/7/bits/stl_algo.h:4868:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = main()::<lambda(int, int)>]'
ho_t1.cpp:22:3:   required from here
/usr/include/c++/7/bits/predefined_ops.h:215:11: error: no match for call to '(main()::<lambda(int, int)>) (data&, data&)'
  { return bool(_M_comp(__val, *__it)); }
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:20:43: note: candidate: main()::<lambda(int, int)>
  sort(a + 1, a + n + 2, [&](data a, data b) {
                                           ^
ho_t1.cpp:20:43: note:   no known conversion for argument 1 from 'data' to 'int'
In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/7/bits/specfun.h:45,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from ho_t1.cpp:1:
/usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = data*; _Value = data; _Compare = main()::<lambda(int, int)>]':
/usr/include/c++/7/bits/stl_heap.h:133:48:   required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = data*; _Distance = long int; _Tp = data; _Compare = __gnu_cxx::__ops::_Iter_comp_val<main()::<lambda(int, int)> >]'
/usr/include/c++/7/bits/stl_heap.h:237:23:   required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = data*; _Distance = long int; _Tp = data; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int, int)> >]'
/usr/include/c++/7/bits/stl_heap.h:342:22:   required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int, int)> >]'
/usr/include/c++/7/bits/stl_algo.h:1672:23:   required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int, int)> >]'
/usr/include/c++/7/bits/stl_algo.h:1933:25:   required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int, int)> >]'
/usr/include/c++/7/bits/stl_algo.h:1948:27:   required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = data*; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int, int)> >]'
/usr/include/c++/7/bits/stl_algo.h:1968:25:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int, int)> >]'
/usr/include/c++/7/bits/stl_algo.h:4868:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = main()::<lambda(int, int)>]'
ho_t1.cpp:22:3:   required from here
/usr/include/c++/7/bits/predefined_ops.h:177:11: error: no match for call to '(main()::<lambda(int, int)>) (data&, data&)'
  { return bool(_M_comp(*__it, __val)); }
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:20:43: note: candidate: main()::<lambda(int, int)>
  sort(a + 1, a + n + 2, [&](data a, data b) {
                                           ^
ho_t1.cpp:20:43: note:   no known conversion for argument 1 from 'data' to 'int'
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
ho_t1.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i].x);
   ~~~~~^~~~~~~~~~~~~~~
ho_t1.cpp:19:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  } for(int i = 1; i <= n; i++) scanf("%d", &b[i]);
                                ~~~~~^~~~~~~~~~~~~