This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
int n,x,maxi=0;
cin>>n>>x;
vector<int>list(n);
for(int i=0;i<n;i++){
cin>>list[i];
}
vector<vector<pair<int,set<int> > > >DP(n,vector<pair<int,set<int> > >(n));
vector<bool> visto(n,false);
pair<int,set<int> > maximo;
for(int i=0;i<n;i++){
DP[i][i].first=list[i];
DP[i][i].second.insert(i);
maximo=DP[i][i];
for(int j=i+1;j<n;j++){
for(int q=i;q<j;q++){
if(list[j]>DP[i][q].first&&DP[i][q].second.size()+1>DP[i][j].second.size()){
DP[i][j]=DP[i][q];
DP[i][j].first=list[j];
DP[i][j].second.insert(j);
if(DP[i][j].second.size()>maximo.second.size())maximo=DP[i][j];
}
}
if(DP[i][j].first==0)DP[i][j]=maximo;
}
int t=maximo.second.size();
maxi=max(t,maxi);
}
cout<<maxi;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |