Submission #543390

#TimeUsernameProblemLanguageResultExecution timeMemory
543390fcwFeast (NOI19_feast)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define st first #define nd second using lint = int64_t; constexpr int mod = int(1e9) + 7; constexpr int inf = 0x3f3f3f3f; constexpr int ninf = 0xcfcfcfcf; constexpr lint linf = 0x3f3f3f3f3f3f3f3f; const long double pi = acosl(-1.0); // Returns -1 if a < b, 0 if a = b and 1 if a > b. int cmp_double(double a, double b = 0, double eps = 1e-9) { return a + eps > b ? b + eps > a ? 0 : 1 : -1; } using namespace std; const lint INF = 3e14 + 10; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, k; cin>>n>>k; vector<lint>a(n); for(int i=0;i<n;i++) cin>>a[i]; double lo = 0, hi = INF; for(int i=0;i<100;i++){ double mid = (lo + hi) / 2; vector<array<pair<double, lint>, 2>>dp(n+1); dp[0][0] = {0, 0}, dp[0][1] = {-INF, 0}; for(int i=0;i<n;i++){ dp[i+1][1] = max(make_pair(dp[i][1].st + a[i], dp[i][1].nd), make_pair(dp[i][0].st + a[i] - mid, dp[i][0].nd + 1)); dp[i+1][0] = max(dp[i][0], dp[i][1]); } if(max(dp[n][0], dp[n][1]).nd >= k) lo = mid; else hi = mid; } double mid = hi; vector<array<double, 2>>dp(n+1); dp[0][0] = 0, dp[0][1] = -INF; for(int i=0;i<n;i++){ dp[i+1][1] = max(dp[i][1] + a[i], dp[i][0] + a[i] - mid); dp[i+1][0] = max(dp[i][0], dp[i][1]); } cout<< lint(round(dp[n][0], dp[n][1]) + mid * k)<<"\n"; return 0; } /* [ ]Leu o problema certo??? [ ]Ver se precisa de long long [ ]Viu o limite dos fors (é n? é m?) [ ]Tamanho do vetor, será que é 2e5 em vez de 1e5?? [ ]Testar sample [ ]Testar casos de borda [ ]1LL no 1LL << i [ ]Testar mod (é 1e9+7, mesmo?, será que o mod não ficou negativo?) */

Compilation message (stderr)

feast.cpp: In function 'int main()':
feast.cpp:45:38: error: no matching function for call to 'round(std::array<double, 2>::value_type&, std::array<double, 2>::value_type&)'
   45 |  cout<< lint(round(dp[n][0], dp[n][1]) + mid * k)<<"\n";
      |                                      ^
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from feast.cpp:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:298:1: note: candidate: 'double round(double)'
  298 | __MATHCALLX (round,, (_Mdouble_ __x), (__const__));
      | ^~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:298:1: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from feast.cpp:1:
/usr/include/c++/10/cmath:1768:5: note: candidate: 'template<class _Tp> constexpr typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type std::round(_Tp)'
 1768 |     round(_Tp __x)
      |     ^~~~~
/usr/include/c++/10/cmath:1768:5: note:   template argument deduction/substitution failed:
feast.cpp:45:38: note:   candidate expects 1 argument, 2 provided
   45 |  cout<< lint(round(dp[n][0], dp[n][1]) + mid * k)<<"\n";
      |                                      ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from feast.cpp:1:
/usr/include/c++/10/cmath:1760:3: note: candidate: 'constexpr long double std::round(long double)'
 1760 |   round(long double __x)
      |   ^~~~~
/usr/include/c++/10/cmath:1760:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/cmath:1756:3: note: candidate: 'constexpr float std::round(float)'
 1756 |   round(float __x)
      |   ^~~~~
/usr/include/c++/10/cmath:1756:3: note:   candidate expects 1 argument, 2 provided