Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <vector>
- using namespace std;
- ifstream ifs("input.txt");
- ofstream ofs("output.txt");
- vector<int> a;
- int f(){
- int max=0,n=a.size();
- vector<int> t(n);
- t[0]=1;
- for(int i=1;i<n;i++){
- int m=0;
- for(int j=0;j<i;j++){
- if(a[i]>a[j]&&t[j]>m){
- t[i]=t[j]+1;
- m=t[j];
- if(t[i]>max)max=t[i];
- };
- if(!t[i])t[i]++;
- };
- };
- return max;
- };
- int main()
- {
- int n,k,max,h=0;
- ifs>>n>>k;
- vector<int> v(n);
- for(int i=0;i<n;i++)ifs>>v[i];
- vector<int> w=v;
- for(int i=0;i<w.size()/2;i++)swap(w[i],w[w.size()-1-i]);
- for(int i=0;i<k;i++)
- if(i%2){a.insert(a.end(),w.begin(),w.end());}
- else{a.insert(a.end(),v.begin(),v.end());}
- ofs<<f();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement