248202026-02-15 21:06:45999Virágos rét (50 pont)cpp17Compilation error
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    int n,k;cin>>n>>k;
    vector<int> v(n+1),dp(n+1),hany(n+1);
    for(int i = 1;i<=n;i++){
        int a;cin>>a;
        v[i]=a+v[i-1];
    }
    for(int i = k;i<=n;i++){
        dp[i]=dp[i-1]+(v[i]>v[i-1]?max(0,v[i-k+1]-(k-v[i]+v[i-k+1])+1):0);
        cerr<<dp[i]<<' ';
    }
    cout<<dp[n]<<endl;
}
//i.nel: i-k+1 tol kezdodhet, tehat v[i]-v[i-k+1] darab van ahol nem kezdodhet, de mindenkepp benne vannak, ehez meg kell k- ennyi 
//ha v:0 1 2 2 2 2 3 akkor a 7.-nel ugye k=3 tehat v[7]-v[5] darab mar megvan, ez 1 kell meg 2,v[i-k+1] darab -2+1 lehet az eleje
Compilation error
open /var/local/lib/isolate/442/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:15:39: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   15 |         dp[i]=dp[i-1]+(v[i]>v[i-1]?max(0,v[i-k+1]-(k-v[i]+v[i-k+1])+1):0);
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/12/bits/specfun.h:45,
                 from /usr/include/c++/12/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/stdc++.h:41,
                 from main.cpp:3:
/usr/include/c++/12/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++/12/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
main.cpp:15:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   15 |         dp[i]=dp[i-1]+(v[i]>v[i-1]?max(0,v[i-k+1]-(k-v[i]+v[i-k+1])+1):0);
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/12/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++/12/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
main.cpp:15:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   15 |         dp[i]=dp[i-1]+(v[i]>v[i-1]?max(0,v[i-k+1]-(k-v[i]+v[i-k+1])+1):0);
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/...