Submission #883372

# Submission time Handle Problem Language Result Execution time Memory
883372 2023-12-05T08:35:39 Z alexdd Divide and conquer (IZhO14_divide) C++17
Compilation error
0 ms 0 KB
/******************************************************************************
                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e18;
int n;
int x[100005];
int g[100005];
int d[100005];
int prefd[100005];
int prefg[100005];
map<int,int> mp;
map<int,int> nrm;
int cate=0;
int aint[400005];
void build(int nod, int st, int dr)
{
    aint[nod]=-INF;
    if(st==dr)
        return;
    int mij=(st+dr)/2;
    build(nod*2,st,mij);
    build(nod*2+1,mij+1,dr);s
}
void upd(int nod, int st, int dr, int poz, int newv)
{
    if(st==dr)
    {
        aint[nod] = max(aint[nod],newv);
        return;
    }
    int mij=(st+dr)/2;
    if(poz<=mij) upd(nod*2,st,mij,poz,newv);
    else upd(nod*2+1,mij+1,dr,poz,newv);
    aint[nod] = max(aint[nod*2], aint[nod*2+1]);
}
int qry(int nod, int st, int dr, int le, int ri)
{
    if(le>ri)
        return -INF;
    if(le==st && dr==ri)
        return aint[nod];
    return max(qry(nod*2,st,mij,le,min(mij,ri)),
                qry(nod*2+1,mij+1,dr,max(mij+1,le),ri));
}
signed main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x[i]>>g[i]>>d[i];
        prefd[i] = prefd[i-1] + d[i];
        prefg[i] = prefg[i-1] + g[i];
        mp[x[i]-prefd[i]]++;
    }
    mp[0]++;
    for(auto it:mp)
    {
        if(it.second==0)
            continue;
        nrm[it.first]=++cate;
    }
    build(1,1,cate);
    int mxm=0;
    upd(1,1,cate,nrm[0],0);
    for(int i=1;i<=n;i++)
    {
        upd(1,1,cate,nrm[x[i]-prefd[i]],-g[i]);
        mxm = max(mxm, g[i]+qry(1,1,cate,nrm[x[i]-prefd[i]]));
    }
    cout<<mxm;
    return 0;
}

Compilation message

divide.cpp: In function 'void build(long long int, long long int, long long int)':
divide.cpp:27:29: error: 's' was not declared in this scope; did you mean 'st'?
   27 |     build(nod*2+1,mij+1,dr);s
      |                             ^
      |                             st
divide.cpp: In function 'long long int qry(long long int, long long int, long long int, long long int, long long int)':
divide.cpp:47:29: error: 'mij' was not declared in this scope
   47 |     return max(qry(nod*2,st,mij,le,min(mij,ri)),
      |                             ^~~
divide.cpp: In function 'int main()':
divide.cpp:73:60: error: too few arguments to function 'long long int qry(long long int, long long int, long long int, long long int, long long int)'
   73 |         mxm = max(mxm, g[i]+qry(1,1,cate,nrm[x[i]-prefd[i]]));
      |                                                            ^
divide.cpp:41:5: note: declared here
   41 | int qry(int nod, int st, int dr, int le, int ri)
      |     ^~~