Submission #1366300

#TimeUsernameProblemLanguageResultExecution timeMemory
1366300sodooSequence (APIO23_sequence)C++20
Compilation error
0 ms0 KiB
#include "sequence.h"
#include<bits/stdc++.h>
using namespace std;
int sequence(int N,vector<int> A){
	int mx=0;
	for(int i=0;i<N;i++){
		for(int j=i;j<N;j++){
			vector<int> v;
			for(int t=i;t<=j;t++){
				v.push_back(A[t]);
			}
			sort(v.begin(),v.end());
			int n=v.size();
			int sumy=0,sumx=0
			int l=(n-1)/2,r=n/2,y=v[l],x=v[r];
			for(int t=0;t<n;t++){
				if(v[t]==y) sumy+=1;
				if(v[t]==x) sumx+=1;
			}
			int b=max(sumy,sumx);
			mx=max(mx,b);
		}
	}
	return mx;
}
/*int main(){
	int rr;
	vector<int> vv;
	cin>>rr;
	for(int i=1;i<=rr;i++){
		int e;
		cin>>e;
		vv.push_back(e);
	}
	int ee=sequence(rr,vv);
	cout<<ee;
}*/

Compilation message (stderr)

sequence.cpp: In function 'int sequence(int, std::vector<int>)':
sequence.cpp:15:25: error: expected ',' or ';' before 'int'
   15 |                         int l=(n-1)/2,r=n/2,y=v[l],x=v[r];
      |                         ^~~
sequence.cpp:17:42: error: 'y' was not declared in this scope
   17 |                                 if(v[t]==y) sumy+=1;
      |                                          ^
sequence.cpp:18:42: error: 'x' was not declared in this scope
   18 |                                 if(v[t]==x) sumx+=1;
      |                                          ^