답안 #949090

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
949090 2024-03-19T00:44:31 Z sondos225 Vudu (COCI15_vudu) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>using ordered_set = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;//find_by_order(ind);
//order_of_key()
//#define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define yes "YES"
#define no "NO"
#define bigg INT_MAX
#define debug(x) cout<<(#x)<<" = " <<x<<endl;
#define all(x) x.begin(),x.end()
#define sz size()
#define nn '\n'
#define mms(x,y) memset(x,y,sizeof(x))
#define forr(i,j,n) for (int i=j; i<n; i++)
#define forn(i,j,n) for (int i=j; i>n; i--)
#define fi first
#define se second
#define la "LA"
#define cinn(x,y) for(int i=0; i<y; i++) cin>>x[i];
#define pii pair<int,int>
signed main()
{
//    #ifndef LOCAL
//    freopen("lifeguards.in","r",stdin);
//    freopen("lifeguards.out","w", stdout);
//    #endif
    fast
    int n;
    cin>>n;
    int a[n];
    forr(i,0,n) cin>>a[i];
    int p;
    cin>>p;
    int sm[n];
    sm[0]=a[0];
    //int b[n];
    //b[0]=sm[0];
    //vector<int> s;
    ordered_set<int> s;
   // s.pb(0);
    s.insert(a[0]-p);
    s.insert(0);
    int ans=0;
    forr(i,1,n)
    {
        sm[i]=sm[i-1]+a[i];
        int x=sm[i]-(p*(i+1));

    //    sort(all(s));
        //cout<<no<<x<<endl;
       // for(auto y:s) cout<<la<<y<<endl;
       //cout<<x<<endl;
        int w=s.order_of_key(x+1);
        //w--;
       // cout<<w<<endl;
        s.insert(x);
       // (lower_bound(all(s),x+1)-s.begin());
        //w--;
       // int d=
      // if (w==s.sz) w=0;
     // w++;

      // cout<<w<<endl;
        ans+=max(0ll,w);


      //  b[i]=;
    }
    cout<<ans;
    return 0;
}

Compilation message

vudu.cpp: In function 'int main()':
vudu.cpp:69:23: error: no matching function for call to 'max(long long int, int&)'
   69 |         ans+=max(0ll,w);
      |                       ^
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 vudu.cpp:1:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
vudu.cpp:69:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   69 |         ans+=max(0ll,w);
      |                       ^
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 vudu.cpp:1:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
vudu.cpp:69:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   69 |         ans+=max(0ll,w);
      |                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from vudu.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
vudu.cpp:69:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   69 |         ans+=max(0ll,w);
      |                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from vudu.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
vudu.cpp:69:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   69 |         ans+=max(0ll,w);
      |                       ^