Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#define max(a,b) a>b?a:b
using namespace std;
int n,len;
int cnt[100001],hash1[100001],a[100001],now[50000],last[50000];
int readint(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
void work(int i){
	if(flag){
		for( ;i<=n;i++ ){
			int k=max(now[++tle],a[i]);
			int m=lower_bound(hash+1,hash+1+len,k);
			last[++tle]=k;
			cnt[m]++;
		}
		flag=0;
		tle=0;
		memset(now,0,sizeof(now));
		work(i+1);
	}
	else{
		for( ;i<=n;i++ ){
			int k=max(last[++tle],a[i]);
			int m=lower_bound(hash+1,hash+1+len,k);
			now[++tle]=k;
			cnt[m]++;
		}
		flag=1;
		tle=0;
		memset(last,0,sizeof(last));
		work(i+1);
	}
}
int main(){
	n=readint();
	for(int i=1;i<=n;i++){
		a[i]=readint();
		hash1[i]=a[i];
		if(i!=n){
			int k=max(a[i],a[i+1]);
			now.push_back(k);
		}
	}
	len=unique(hash1+1,hash1+1+n)-hash1-1;
	for(int i=1;i<=len;i++) cnt[i]++;
	work(3);
	int ret=(n*(n-1)/2+n)/2+1,ans=0;
	for(int i=1;i<=len;i++){
		ans+=cnt[i];
		if(ans>=ret){
			printf("%d\n", cnt[i]);
			break;
		}
	}
	return 0;
}


Compiler output:
a.cc: In function 'void work(int)':
a.cc:22:12: error: 'flag' was not declared in this scope
   22 |         if(flag){
      |            ^~~~
a.cc:24:41: error: 'tle' was not declared in this scope
   24 |                         int k=max(now[++tle],a[i]);
      |                                         ^~~
a.cc:4:18: note: in definition of macro 'max'
    4 | #define max(a,b) a>b?a:b
      |                  ^
a.cc:25:47: error: missing template arguments before '+' token
   25 |                         int m=lower_bound(hash+1,hash+1+len,k);
      |                                               ^
a.cc:25:54: error: missing template arguments before '+' token
   25 |                         int m=lower_bound(hash+1,hash+1+len,k);
      |                                                      ^
a.cc:30:17: error: 'tle' was not declared in this scope
   30 |                 tle=0;
      |                 ^~~
a.cc:36:42: error: 'tle' was not declared in this scope
   36 |                         int k=max(last[++tle],a[i]);
      |                                          ^~~
a.cc:4:18: note: in definition of macro 'max'
    4 | #define max(a,b) a>b?a:b
      |                  ^
a.cc:37:47: error: missing template arguments before '+' token
   37 |                         int m=lower_bound(hash+1,hash+1+len,k);
      |                                               ^
a.cc:37:54: error: missing template arguments before '+' token
   37 |                         int m=lower_bound(hash+1,hash+1+len,k);
      |                                                      ^
a.cc:42:17: error: 'tle' was not declared in this scope
   42 |                 tle=0;
      |                 ^~~
a.cc: In function 'int main()':
a.cc:54:29: error: request for member 'push_back' in 'now', which is of non-class type 'int [50000]'
   54 |                         now.push_back(k);
      |                             ^~~~~~~~~
a.cc:57:13: error: 'unique' was not declared in this scope
   57 |         len=unique(hash1+1,hash1+1+n)-hash1-1;
      |             ^~~~~~