제출 #296247

#제출 시각아이디문제언어결과실행 시간메모리
296247arayi휴가 (IOI14_holiday)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "holiday.h" #define lli long long int using namespace std; long long int findMaxAttraction(int n, int st, int d, int a[]) { lli pat = 0; for(int l = 0; l <= st; ++l) { priority_queue<lli, vector<lli>, greater<lli> > q; lli sum = 0; for (int r = l; r < n; r++) { sum += a[r]; q.push(a[r]); int sm = min(abs(r - st, l - st)) + 1 + r - l + 1; sm = d - sm; if(sm < 0) continue; while(q.size() > sm) sum -= q.top(), q.pop(); pat = ma(pat, sum); } } return pat; }

컴파일 시 표준 에러 (stderr) 메시지

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:17:44: error: no matching function for call to 'abs(int, int)'
   17 |             int sm = min(abs(r - st, l - st)) + 1 + r - l + 1;
      |                                            ^
In file included from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from holiday.cpp:1:
/usr/include/stdlib.h:774:12: note: candidate: 'int abs(int)'
  774 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/stdlib.h:774:12: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/9/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95,
                 from holiday.cpp:1:
/usr/include/c++/9/bits/valarray_after.h:445:5: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_ValArray, _Tp>, _Tp> std::abs(const std::valarray<_Tp>&)'
  445 |     _DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/valarray_after.h:445:5: note:   template argument deduction/substitution failed:
holiday.cpp:17:44: note:   mismatched types 'const std::valarray<_Tp>' and 'int'
   17 |             int sm = min(abs(r - st, l - st)) + 1 + r - l + 1;
      |                                            ^
In file included from /usr/include/c++/9/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95,
                 from holiday.cpp:1:
/usr/include/c++/9/bits/valarray_after.h:445:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_Expr, _Dom>, typename _Dom::value_type> std::abs(const std::_Expr<_Dom1, typename _Dom1::value_type>&)'
  445 |     _DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/valarray_after.h:445:5: note:   template argument deduction/substitution failed:
holiday.cpp:17:44: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
   17 |             int sm = min(abs(r - st, l - st)) + 1 + r - l + 1;
      |                                            ^
In file included from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from holiday.cpp:1:
/usr/include/c++/9/complex:619:5: note: candidate: 'template<class _Tp> _Tp std::abs(const std::complex<_Tp>&)'
  619 |     abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); }
      |     ^~~
/usr/include/c++/9/complex:619:5: note:   template argument deduction/substitution failed:
holiday.cpp:17:44: note:   mismatched types 'const std::complex<_Tp>' and 'int'
   17 |             int sm = min(abs(r - st, l - st)) + 1 + r - l + 1;
      |                                            ^
In file included from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from holiday.cpp:1:
/usr/include/c++/9/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:79:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/9/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:75:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/9/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:71:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/9/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:61:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/9/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
/usr/include/c++/9/bits/std_abs.h:56:3: note:   candidate expects 1 argument, 2 provided
holiday.cpp:20:28: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |             while(q.size() > sm) sum -= q.top(), q.pop();
      |                   ~~~~~~~~~^~~~
holiday.cpp:21:19: error: 'ma' was not declared in this scope; did you mean 'a'?
   21 |             pat = ma(pat, sum);
      |                   ^~
      |                   a