Language: Java

#include <bits/stdc++.h>

int N;
int M;

struct segtree{
  
  int n;
  long long v[500000];
  long long lazy[500000];
  
  segtree(int n_){
    n=1;
    while(n<n_)n*=2;
    for(int i=0;i<2*n-1;++i){
      v[i]=0;
      lazy[i]=0;
    }
  }

  long long query(int a,int b,long long add){
    return query(0,n,a,b,0,add);
  }

  long long push(int k){
    v[k]+=lazy[k];
    if(2*k+2<2*n-1){
      lazy[2*k+1]+=lazy[k];
      lazy[2*k+2]+=lazy[k];
    }
    lazy[k]=0;
  }
  
  long long query(int l,int r,int a,int b,int k,long long add){
    push(k);
    if(r<=a||b<=l){
      return -(1LL<<60);
    }else if(a<=l&&r<=b){
      lazy[k]+=add;
      push(k);
      return v[k];
    }else{
      long long vl=query(l,(l+r)/2,a,b,2*k+1,add);
      long long vr=query((l+r)/2,r,a,b,2*k+2,add);
      v[k]=std::max(v[2*k+1],v[2*k+2]);
      return std::max(vl,vr);
    }
  }
  
};

int main(){
  
  std::cin>>N;
  std::cin>>M;
  
  std::vector<int> dst[N];
  std::vector<long long> add[N];
  for(int i=0;i<M;++i){
    int l,r;
    long long a;
    std::cin>>l>>r>>a;
    --l;
    --r;
    dst[r].push_back(l);
    add[r].push_back(a);
  }
  
  segtree seg(N);
  for(int i=0;i<N;++i){
    long long sum=0;
    for(int j=0;j<dst[i].size();++j){
      sum+=add[i][j];
    }
    seg.query(i,i+1,sum+std::max(0LL,seg.query(0,i,0)));
    for(int j=0;j<dst[i].size();++j){
      seg.query(dst[i][j],i,add[i][j]);
    }
  }

  std::cout<<std::max(0LL,seg.query(0,N,0))<<std::endl;


  return 0;
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:4: error: unnamed classes are a preview feature and are disabled by default.
int M;
^
  (use --enable-preview to enable unnamed classes)
Main.java:6: error: class, interface, enum, or record expected
struct segtree{
^
Main.java:9: error: class, interface, enum, or record expected
  long long v[500000];
  ^
Main.java:10: error: class, interface, enum, or record expected
  long long lazy[500000];
  ^
Main.java:12: error: class, interface, enum, or record expected
  segtree(int n_){
  ^
Main.java:14: error: class, interface, enum, or record expected
    while(n<n_)n*=2;
    ^
Main.java:15: error: class, interface, enum, or record expected
    for(int i=0;i<2*n-1;++i){
    ^
Main.java:15: error: class, interface, enum, or record expected
    for(int i=0;i<2*n-1;++i){
                ^
Main.java:15: error: class, interface, enum, or record expected
    for(int i=0;i<2*n-1;++i){
                        ^
Main.java:17: error: class, interface, enum, or record expected
      lazy[i]=0;
      ^
Main.java:18: error: class, interface, enum, or record expected
    }
    ^
Main.java:23: error: class, interface, enum, or record expected
  }
  ^
Main.java:27: error: class, interface, enum, or record expected
    if(2*k+2<2*n-1){
    ^
Main.java:29: error: class, interface, enum, or record expected
      lazy[2*k+2]+=lazy[k];
      ^
Main.java:30: error: class, interface, enum, or record expected
    }
    ^
Main.java:32: error: class, interface, enum, or record expected
  }
  ^
Main.java:36: error: class, interface, enum, or record expected
    if(r<=a||b<=l){
    ^
Main.java:38: error: class, interface, enum, or record expected
    }else if(a<=l&&r<=b){
    ^
Main.java:40: error: class, interface, enum, or record expected
      push(k);
      ^
Main.java:41: error: class, interface, enum, or record expected
      return v[k];
      ^
Main.java:42: error: class, interface, enum, or record expected
    }else{
    ^
Main.java:44: error: class, interface, enum, or record expected
      long long vr=query((l+r)/2,r,a,b,2*k+2,add);
      ^
Main.java:45: error: class, interface, enum, or record expected
      v[k]=std::max(v[2*k+1],v[2*k+2]);
      ^
Main.java:46: error: class, interface, enum, or record expected
      return std::max(vl,vr);
      ^
Main.java:47: error: class, interface, enum, or record expected
    }
    ^
Main.java:54: error: not a statement
  std::cin>>N;
          ^
Main.java:55: error: not a statement
  std::cin>>M;
          ^
Main.java:57: error: not a statement
  std::vector<int> dst[N];
                 ^
Main.java:58: error: not a statement
  std::vector<long long> add[N];
             ^
Main.java:58: error: not a statement
  std::vector<long long> add[N];
                   ^
Main.java:58: error: not a statement
  std::vector<long long> add[N];
                            ^
Main.java:61: error: not a statement
    long long a;
    ^
Main.java:62: error: not a statement
    std::cin>>l>>r>>a;
                  ^
Main.java:69: error: not a statement
  segtree seg(N);
              ^
Main.java:71: error: not a statement
    long long sum=0;
    ^
Main.java:75: error: not a statement
    seg.query(i,i+1,sum+std::max(0LL,seg.query(0,i,0)));
                                   ^
Main.java:81: error: not a statement
  std::cout<<std::max(0LL,seg.query(0,N,0))<<std::endl;
           ^
Main.java:81: error: not a statement
  std::cout<<std::max(0LL,seg.query(0,N,0))<<std::endl;
                        ^
Main.java:81: error: not a statement
  std::cout<<std::max(0LL,seg.query(0,N,0))<<std::endl;
                                             ^
Main.java:58: error: ';' expected
  std::vector<long long> add[N];
                       ^
Main.java:61: error: ';' expected
    long long a;
        ^
Main.java:69: error: ';' expected
  segtree seg(N);
             ^
Main.java:69: error: ';' expected
  segtree seg(N);
               ^
Main.java:71: error: ';' expected
    long long sum=0;
        ^
Main.java:75: error: ')' or ',' expected
    seg.query(i,i+1,sum+std::max(0LL,seg.query(0,i,0)));
                                ^
Main.java:75: error: ';' expected
    seg.query(i,i+1,sum+std::max(0LL,seg.query(0,i,0)));
                                    ^
Main.java:75: error: ';' expected
    seg.query(i,i+1,sum+std::max(0LL,seg.query(0,i,0)));
                                                     ^
Main.java:81: error: ';' expected
  std::cout<<std::max(0LL,seg.query(0,N,0))<<std::endl;
                     ^
Main.java:81: error: ';' expected
  std::cout<<std::max(0LL,seg.query(0,N,0))<<std::endl;
                         ^
Main.java:81: error: ';' expected
  std::cout<<std::max(0LL,seg.query(0,N,0))<<std::endl;
                                          ^
52 errors