Submission #1042156

# Submission time Handle Problem Language Result Execution time Memory
1042156 2024-08-02T15:29:42 Z Minbaev Divide and conquer (IZhO14_divide) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define int long long int
using namespace std;
struct data{
    int x,g,d;
};
data a[100001];
int n,i,drive[100001],gold[100001],vec[100001],res,l,r,m;
main(){
    scanf("%lld",&n);
    for(i=1;i<=n;i++){
        scanf("%lld%lld%lld",&a[i].x,&a[i].g,&a[i].d);
        gold[i]=gold[i-1]+a[i].g;
        drive[i]=drive[i-1]+a[i].d;
        vec[i]=drive[i]-a[i].x;
    }
    for(i=n-1;i>0;i--)vec[i]=max(vec[i],vec[i+1]);
    for(i=1;i<=n;i++){
        l=i;
        r=n;
        while(l<r){
            m=(l+r+1)>>1;
            if(vec[m]>=drive[i-1]-a[i].x)l=m;
            else r=m-1;
        }
        res=max(res,gold[r]-gold[i-1]);
    }
    printf("%lld",res);
}

Compilation message

divide.cpp:7:1: error: reference to 'data' is ambiguous
    7 | data a[100001];
      | ^~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from divide.cpp:1:
/usr/include/c++/10/bits/range_access.h:319:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)'
  319 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:310:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  310 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:300:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  300 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:290:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  290 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
divide.cpp:4:8: note:                 'struct data'
    4 | struct data{
      |        ^~~~
divide.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main(){
      | ^~~~
divide.cpp: In function 'int main()':
divide.cpp:12:31: error: 'a' was not declared in this scope
   12 |         scanf("%lld%lld%lld",&a[i].x,&a[i].g,&a[i].d);
      |                               ^
divide.cpp:23:35: error: 'a' was not declared in this scope
   23 |             if(vec[m]>=drive[i-1]-a[i].x)l=m;
      |                                   ^
divide.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%lld",&n);
      |     ~~~~~^~~~~~~~~~~