Language: C++

#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
class MinimizeAbsoluteDifferenceDiv1
{
    public:
vector <int> findTuple(vector <int> x)
{


}
};
int main()
{
    int a,b;
    while(cin>>a>>b){
        int w[100005]={};
        int w1[100005]={};
        int x[100005]={};
        for(int i=1;i<=a;i++){
            cin>>w[i]>>x[i];
        }
        for(int i=1;i<=a;i++)
            w[i]=w[i-1]+w[i];

        int t1[100005]={};
        int t2[100005]={};
        int ans=0;
        for(int i=1;i<=a;i++){
            w[i]=w[i]-x[i];
            w1[i]=w[a]-w[i-1]-(b-x[i]);
            t1[i]=w[i]-x[i];

            t2[i]=w1[i]-(b-x[i]);

            ans=max(ans,w1);
            ans=max(ans,w);
        }
        int num=0;
        for(int i=1;i<=a;i++){
            ans=max(ans,num+w2[i]);
            num=max(num,t1[i]);
        }
        num=0;
        for(int i=a;i>=1;i--){
                   ans=max(ans,num+w1[i]);
            num=max(num,t2[i]);

        }
        cout<<ans<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In member function 'std::vector<int> MinimizeAbsoluteDifferenceDiv1::findTuple(std::vector<int>)':
a.cc:27:1: warning: no return statement in function returning non-void [-Wreturn-type]
   27 | }
      | ^
a.cc: In function 'int main()':
a.cc:52:20: error: no matching function for call to 'max(int&, int [100005])'
   52 |             ans=max(ans,w1);
      |                 ~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:52:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'int [100005]')
   52 |             ans=max(ans,w1);
      |                 ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:52:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   52 |             ans=max(ans,w1);
      |                 ~~~^~~~~~~~
a.cc:53:20: error: no matching function for call to 'max(int&, int [100005])'
   53 |             ans=max(ans,w);
      |                 ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:53:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'int [100005]')
   53 |             ans=max(ans,w);
      |                 ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:53:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   53 |             ans=max(ans,w);
      |                 ~~~^~~~~~~
a.cc:57:29: error: 'w2' was not declared in this scope; did you mean 't2'?
   57 |             ans=max(ans,num+w2[i]);
      |                             ^~
      |                             t2