14822022-11-13 21:06:11tomi7Völgy (100 pont)cpp11Forditási hiba
int main() {
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> jobb(n);
	vector<int> bal(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int legnagyobb=-1;
    jobb[n-1]=-1;
	bal[0]=-1;
	for(int i=1;i<n;i++){ 
		for(int j=i-1;1;){ 
		    if(a[i]>a[j]){
			     if(bal[j]==-1){
				     bal[i]=-1;  
					 break;
			     }
			     if(bal[j]!=-1){
				     j=bal[j];
			     }
		    }else{
				bal[i]=j;
				if(i-j>1){
			         legnagyobb=max(i-j, legnagyobb);
				}   
				break;
			}
	    }
	}

	for(int i=n-2;i>=0;i--){
		for(int j=i+1;1;){
	//		cout << "Uj j " << j << '\n';
		    if(a[i]>a[j]){
			     if(jobb[j]==-1){
				     jobb[i]=-1;
	//				 cout << "Elso if : a[i]: " << a[i] << " a[j]: " << a[j] << " jobb[i]: " << jobb[i] << '\n';
					 break;
			     }
			     if(bal[j]!=-1){
				     j=jobb[j];
	//				 cout << "Masodik if : a[i]: " << a[i] << " a[j]: " << a[j] << " jobb[i]: " << jobb[i] << '\n';
			     }
		    }else{
				jobb[i]=j;
				if(j-i>1){
			         legnagyobb=max(j-i, legnagyobb);
				}
	//			cout << "Else : a[i]: " << a[i] << " a[j]: " << a[j] << " jobb[i]: " << jobb[i] << '\n';
				break;
			}
	    }
	}
	cout<<legnagyobb<<'\n';





	
	







	//for(int i=0; i<n; i++) {
	//	cout<<"BAL"<<bal[i]<<" ";
//	}
//	cout<<endl;
//	for(int i=0; i<n; i++) {
//		cout<<"JOBB"<<jobb[i]<<" ";
//	}
//	cout<<endl;
}
Forditási hiba
exit status 1
main.cpp: In function 'int main()':
main.cpp:3:9: error: 'cin' was not declared in this scope
    3 |         cin>>n;
      |         ^~~
main.cpp:4:9: error: 'vector' was not declared in this scope
    4 |         vector<int> a(n);
      |         ^~~~~~
main.cpp:4:16: error: expected primary-expression before 'int'
    4 |         vector<int> a(n);
      |                ^~~
main.cpp:5:16: error: expected primary-expression before 'int'
    5 |         vector<int> jobb(n);
      |                ^~~
main.cpp:6:16: error: expected primary-expression before 'int'
    6 |         vector<int> bal(n);
      |                ^~~
main.cpp:8:22: error: 'a' was not declared in this scope
    8 |                 cin>>a[i];
      |                      ^
main.cpp:11:5: error: 'jobb' was not declared in this scope
   11 |     jobb[n-1]=-1;
      |     ^~~~
main.cpp:12:9: error: 'bal' was not declared in this scope
   12 |         bal[0]=-1;
      |         ^~~
main.cpp:15:24: error: 'a' was not declared in this scope
...