Language: Java

// Author : Rifayat Samee (Sanzee)
// Problem :
// Algorithm:

/*

*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxval = 200005;
ll tree[4*maxval+5];
void make_tree(int i,int low,int high,const vector<int>&A){
    if(low == high){
        tree[i] = 0;
        return;
    }
    int mid = (low + high) / 2;
    make_tree(2*i,low,mid,A);
    make_tree(2*i+1,mid+1,high,A);
    tree[i] = max(tree[2*i],tree[2*i+1]);
}
void update(int i,int low,int high,ll val,ll h,const vector<int>&A){
    if(low == high){
        tree[i] = val;
        return;
    }
    int mid = (low + high)/2;
    if(h <=mid) update(2*i,low,mid,val,h,A);
    else
        update(2*i+1,mid+1,high,val,h,A);
    tree[i] = max(tree[2*i],tree[2*i+1]);
}
ll query(int i,int low,int high,int a,int b){
    if(high < a || low > b) return 0;
    if(low>=a && high <=b){
        return tree[i];
    }
    int mid = (low + high)/2;
    return max(query(2*i,low,mid,a,b),query(2*i+1,mid+1,high,a,b));
}
int main(){

	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
    int n;
    scanf("%d",&n);
    vector<int>H(n+1);
    vector<int>A(n+1);
    int maxh = 0;
    for(int i=0;i<n;i++){
        scanf("%d",&H[i]);
        maxh = max(maxh,H[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    make_tree(1,0,maxh,A);
    ll res = 0;
    for(int i=0;i<n;i++){
        ll h = H[i];
        ll val = query(1,0,maxh,0,h-1);
        res = max(res,A[i]+val);
        update(1,0,maxh,val+A[i],h,A);
    }
    printf("%lld\n",res);
	return 0;
}


Compiler output:
Main.java:8: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:8: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:10: error: class, interface, enum, or record expected
typedef long long ll;
^
Main.java:11: error: class, interface, enum, or record expected
const int maxval = 200005;
^
Main.java:12: error: class, interface, enum, or record expected
ll tree[4*maxval+5];
^
Main.java:13: error: unnamed classes are a preview feature and are disabled by default.
void make_tree(int i,int low,int high,const vector<int>&A){
^
  (use --enable-preview to enable unnamed classes)
Main.java:13: error: illegal start of type
void make_tree(int i,int low,int high,const vector<int>&A){
                                      ^
Main.java:13: error: class, interface, enum, or record expected
void make_tree(int i,int low,int high,const vector<int>&A){
                                                  ^
Main.java:16: error: class, interface, enum, or record expected
        return;
        ^
Main.java:17: error: class, interface, enum, or record expected
    }
    ^
Main.java:19: error: class, interface, enum, or record expected
    make_tree(2*i,low,mid,A);
    ^
Main.java:20: error: class, interface, enum, or record expected
    make_tree(2*i+1,mid+1,high,A);
    ^
Main.java:21: error: class, interface, enum, or record expected
    tree[i] = max(tree[2*i],tree[2*i+1]);
    ^
Main.java:22: error: class, interface, enum, or record expected
}
^
Main.java:26: error: class, interface, enum, or record expected
        return;
        ^
Main.java:27: error: class, interface, enum, or record expected
    }
    ^
Main.java:29: error: class, interface, enum, or record expected
    if(h <=mid) update(2*i,low,mid,val,h,A);
    ^
Main.java:30: error: class, interface, enum, or record expected
    else
    ^
Main.java:32: error: class, interface, enum, or record expected
    tree[i] = max(tree[2*i],tree[2*i+1]);
    ^
Main.java:33: error: class, interface, enum, or record expected
}
^
Main.java:36: error: class, interface, enum, or record expected
    if(low>=a && high <=b){
    ^
Main.java:38: error: class, interface, enum, or record expected
    }
    ^
Main.java:40: error: class, interface, enum, or record expected
    return max(query(2*i,low,mid,a,b),query(2*i+1,mid+1,high,a,b));
    ^
Main.java:41: error: class, interface, enum, or record expected
}
^
Main.java:47: error: class, interface, enum, or record expected
    scanf("%d",&n);
    ^
Main.java:48: error: <identifier> expected
    vector<int>H(n+1);
                  ^
Main.java:49: error: <identifier> expected
    vector<int>A(n+1);
                  ^
Main.java:51: error: class, interface, enum, or record expected
    for(int i=0;i<n;i++){
    ^
Main.java:51: error: class, interface, enum, or record expected
    for(int i=0;i<n;i++){
                ^
Main.java:51: error: class, interface, enum, or record expected
    for(int i=0;i<n;i++){
                    ^
Main.java:53: error: class, interface, enum, or record expected
        maxh = max(maxh,H[i]);
        ^
Main.java:54: error: class, interface, enum, or record expected
    }
    ^
Main.java:55: error: class, interface, enum, or record expected
    for(int i=0;i<n;i++){
                ^
Main.java:55: error: class, interface, enum, or record expected
    for(int i=0;i<n;i++){
                    ^
Main.java:57: error: class, interface, enum, or record expected
    }
    ^
Main.java:60: error: class, interface, enum, or record expected
    for(int i=0;i<n;i++){
    ^
Main.java:60: error: class, interface, enum, or record expected
    for(int i=0;i<n;i++){
                ^
Main.java:60: error: class, interface, enum, or record expected
    for(int i=0;i<n;i++){
                    ^
Main.java:63: error: class, interface, enum, or record expected
        res = max(res,A[i]+val);
        ^
Main.java:64: error: class, interface, enum, or record expected
        update(1,0,maxh,val+A[i],h,A);
        ^
Main.java:65: error: class, interface, enum, or record expected
    }
    ^
Main.java:67: error: class, interface, enum, or record expected
	return 0;
	^
Main.java:68: error: class, interface, enum, or record expected
}
^
43 errors