Submission #817758

# Submission time Handle Problem Language Result Execution time Memory
817758 2023-08-09T15:46:26 Z t6twotwo Measures (CEOI22_measures) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FFOR(i,a,b,c) for(int i=(a);(c)>0?i<=(b):i>=(b);i+=(c))
#define FOOR(i,a,b) FFOR(i,a,(b)-1,1)
#define ROOF(i,a,b) FFOR(i,(b)-1,a,-1)
#define FOR(i,n) FOOR(i,0,n)
#define ROF(i,n) ROOF(i,0,n)
#define FORR(x,v) for(auto &x:v)
#define vc vector
#define sz(v) (int)((v).size())
#define bg begin()
#define en end()
#define em empty()
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define ppb pop_back()
#define eb emplace_back
#define bk back()
#define fr front()
#define pp pop()
#define all(v) (v).begin(),(v).end()
#define lla(v) (v).rbegin(),(v).rend()
#define f first
#define s second
struct node {
    ll sum, pre, suf, best;
    node(){sum=pre=suf=best=0;}
    node(ll a){sum=a;pre=suf=best=min(a,0ll);}
};
node operator+(const node &a, const node &b) {
    node c;
    c.sum=a.sum+b.sum;
    c.pre=min(a.pre,a.sum+b.pre);
    c.suf=min(b.suf,b.sum+a.suf);
    c.best=min({a.best,b.best,a.suf+b.pre});
    return c;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M,D;
    cin>>N>>M>>D;
    if(M<=10){
        vc<int> a(N);
        FORR(x,a)cin>>x;
        FOR(i,M){
            int b;
            cin>>b;
            a.pb(b);
            sort(all(a));
            ll s=0,ans=0;
            FOOR(j,1,sz(a)){
                int k=a[j]-a[j-1]-D;
                s=min(k,s+k);
                ans=min(ans,s);
            }
            ans=-ans;
            if(ans%2==1){
                cout<<ans/2<<"."<<5<<" ";
            }else{
                cout<<ans/2<<" ";
            }
        }
        return 0;
    }
    vc<int> b(M);
    vc<pair<int,int>> p(M);
    FOR(i,M){
        cin>>b[i];
        p[i]={b[i],i};
    }
    sort(all(p));
    vc<int> pos(M);
    FOR(i,M) pos[p[i].s]=i;
    vc<node> st(2*M);
    auto upd = [&](int i, ll v) {
        for(st[i+=M]=v;i/=2;) {
            st[i]=st[i*2]+st[i*2+1];
        }
    };
    set<int> s;
    FOR(i,M){
        auto it=s.ub(pos[i]);
        if(it!=s.bg){
            upd(pos[i],b[i]-p[*prev(it)].f-D);
        }
        if(it!=s.en){
            upd(*it,p[*it].f-b[i]-D);
        }
        s.insert(pos[i]);
        ll ans=-st[1].best;
        if(ans%2==1){
            cout<<ans/2<<"."<<5<<" ";
        }else{
            cout<<ans/2<<" ";
        }
    }
    return 6/22;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:56:28: error: no matching function for call to 'min(int&, ll)'
   56 |                 s=min(k,s+k);
      |                            ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
Main.cpp:56:28: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   56 |                 s=min(k,s+k);
      |                            ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
Main.cpp:56:28: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   56 |                 s=min(k,s+k);
      |                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
Main.cpp:56:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   56 |                 s=min(k,s+k);
      |                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
Main.cpp:56:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   56 |                 s=min(k,s+k);
      |                            ^